Running all Nastran input .bdf files contained in a folder using Matlab
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
1 Comment
KORAY
on 23 Jan 2025
- Hi, the problem resolved? I dave the same problem
system ('C:\MSC.Software\NaPa_SE\20241\Nastran\bin\nastran.exe compositeproject.bdf') runs the bdf file and creates f06 files however the workspace is zero? please help me.
Answers (1)
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)
2 Comments
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)
KORAY
on 23 Jan 2025
- I have the same problem
system ('C:\MSC.Software\NaPa_SE\20241\Nastran\bin\nastran.exe compositeproject.bdf') runs the bdf file and creates f06 files however the workspace is zero? please help me.
Categories
Find more on Downloads 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!