save the output of system command using matlab
조회 수: 18 (최근 30일)
이전 댓글 표시
Hello! I am executing a system command via matlab. in the command I am writing the output to a file. when running the code I can find the generated file but I want that file be passed to Matlab as a variable, how can I get to this ? see the code bellow (I want something so that fileA.txt be attributed to cmdout or any thing similar so Matlab can recognize and work directly with the file)
command = 'MyInstuction >fileA.txt';
[status,cmdout] = system(command);
댓글 수: 0
채택된 답변
Steven Lord
2016년 11월 29일
Use concatenation or sprintf to assemble a command for use with the system function that needs to include information from a variable.
myfilename = 'fileA.txt';
command = ['MyInstuction > ' myfilename]
% I left off the semicolon on the previous line deliberately
% so you can see the command to be executed
[status,cmdout] = system(command);
댓글 수: 0
추가 답변 (2개)
Walter Roberson
2016년 11월 28일
Leave off the redirection. Just
command = 'MyInstuction';
[status,cmdout] = system(command);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!