Running all Nastran input .bdf files contained in a folder using Matlab

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

  • 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.

Sign in to comment.

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

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)
  • 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.

Sign in to comment.

Categories

Asked:

on 19 Jun 2021

Commented:

on 23 Jan 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!