Using dos command, how can I change the content of the quotes on every loop

1 view (last 30 days)
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

Accepted Answer

Walter Roberson
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))

More Answers (1)

Jason Ross
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:
  1. 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).
  2. "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.

Categories

Find more on Programming in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!