Using dos command, how can I change the content of the quotes on every loop
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello team,
i want to use the dos command for a program. I need to change the quotes on every loop in order to avoid increasing the size of the program.
Example
dos('xform -ry %1.0f -t %1.0f %1.0f %1.0f something.rad',deg,x,y,z)
This is what I want to create. How can I do this using Dos command, or do you have anything else to suggest.
Thank you in advance
Sotiris Papantoniou
댓글 수: 0
채택된 답변
Walter Roberson
2011년 4월 12일
You mean something like,
dos(sprintf('xform -ry %1.0f -t %1.0f %1.0f %1.0f something.rad',deg,x,y,z))
댓글 수: 0
추가 답변 (1개)
Jason Ross
2011년 4월 12일
You could try building the command string in a loop outside the dos() call and then make the calls.
A simple example is as follows:
A=[1 2 3 4 5];
for i=1:1:5
Ai = num2str(A(i));
cmdstr = ['echome', ' ', Ai];
dos(cmdstr);
end
Output looks like the following, but the number passed as an argument changes from 1 to 5:
c:\temp>echo "my argument is " 1
"my argument is " 1
ans =
0
Notes:
- You will likely want to do something with the result of the dos() command or check the return status, e.g. [status, result] = dos(command).
- "echome" is a batch file in the current working directory that contains "echo "my arg is" %1". If you wanted to expand out to four arguments, you would add %2 %3 %4 to it. You would call "xform", but might want to use a toy example like this to get the formatting figured out first if xform takes a while to run.
댓글 수: 0
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!