Using dos command, how can I change the content of the quotes on every loop
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
Walter Roberson
on 12 Apr 2011
You mean something like,
dos(sprintf('xform -ry %1.0f -t %1.0f %1.0f %1.0f something.rad',deg,x,y,z))
0 Comments
More Answers (1)
Jason Ross
on 12 Apr 2011
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 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!