Use system to run a program in Matlab

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.

답변 (2개)

James Tursa
James Tursa 2014년 7월 9일

1 개 추천

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

H-H
H-H 2014년 7월 10일
No this didn't work- the space is not added to the string. it just creates $e300data1 and an error happens
Right. strcat is trimming the blanks. So ditch strcat:
yourCommand=['$e300 ',nameData2];

댓글을 달려면 로그인하십시오.

Image Analyst
Image Analyst 2014년 7월 10일
편집: Image Analyst 2014년 7월 10일

0 개 추천

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);

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

질문:

H-H
2014년 7월 9일

댓글:

2014년 7월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by