Running all Nastran input .bdf files contained in a folder using Matlab
18 views (last 30 days)
Show older comments
Hello everyone,
I am trying to run a number of nastran input.bdf files contained in a folder using "system "command in matlab
System command works well when i secify onle one file named"1.bdf" like:
system('D:\MSC.Software\MSC_Nastran\20180\bin\nastranw.exe 1.bdf')
But,I have three bdf files in folder, I am trying to run using for loop
I have tried:
..................................................................................
files = dir('*.bdf');
for i = 1 : length(files)
filename = files(K).name;
system('D:\MSC.Software\MSC_Nastran\20180\bin\nastranw.exe filename')
end
.......................................................................................
But it does not start nastran ,rather gives output such as
ans=0
ans=0
ans=0
0 Comments
Answers (1)
dpb
on 19 Jun 2021
Edited: dpb
on 20 Jun 2021
files = dir('*.bdf');
for i = 1 : length(files)
filename = files(K).name;
system('D:\MSC.Software\MSC_Nastran\20180\bin\nastranw.exe filename')
end
in
system('D:\MSC.Software\MSC_Nastran\20180\bin\nastranw.exe filename')
'filename' is contained in the literal string, not the variable filename
cmd=['D:\MSC.Software\MSC_Nastran\20180\bin\nastranw.exe ' files(K).name];
system(cmd)
Depending on system path and where files are located, you might need to pass the fully-qualified name as well...
cmd=['D:\MSC.Software\MSC_Nastran\20180\bin\nastranw.exe ' fullfile(files(K).folder,files(K).name)];
system(cmd)
1 Comment
Image Analyst
on 20 Jun 2021
Be sure to change i and K to k.
files = dir('*.bdf');
for k = 1 : length(files)
filename = files(k).name;
system('D:\MSC.Software\MSC_Nastran\20180\bin\nastranw.exe filename')
end
And to just make super sure that the executable has the full filename of the both files you should do
executablePath = 'D:\MSC.Software\MSC_Nastran\20180\bin\nastranw.exe';
dataFilePath = fullfile(files(k).folder, files(k).name);
commandLine = sprintf('%s %s', executablePath, dataFilePath);
system(commandLine)
See Also
Categories
Find more on Programmatic Model Editing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!