Use system to run a program in Matlab
4 次查看(过去 30 天)
显示 更早的评论
I have a program named "C:\ecl\macros\$e300" which requires a parameter file named "C:\ecl\macros\data1" (without any extension). $e300 is already available in environmental variables of Windows and can be directly run by $e300.
matlab can call and run this program as system('$e300 Parameter').
However this doesn't work:
name='data';
nameData2=strcat(name,num2str(1));
yourCommand=strcat('$e300',{blanks(1)},nameData2);
system(yourCommand);
The error is : Error using system Argument must contain a string.
0 个评论
回答(2 个)
James Tursa
2014-7-9
You have inadvertantly used curly braces in the formation of your string, which has turned the entire result into a cell array. Try this instead:
yourCommand=strcat('$e300',blanks(1),nameData2);
2 个评论
James Tursa
2014-7-10
Right. strcat is trimming the blanks. So ditch strcat:
yourCommand=['$e300 ',nameData2];
Image Analyst
2014-7-10
编辑:Image Analyst
2014-7-10
Why can't you just do
system('$e300 C:\ecl\macros\data1');
??? If there are any variables in your command string, then use sprintf(), for example:
myNumber = 1; % Your variable that changes all the time.
commandLine = sprintf('$e300 C:\\ecl\\macros\\data%d', myNumber);
system(commandLine);
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 System Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!