Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: MATLAB 'system' function help

  1. Aug 26, 2010 #1
    Hi,
    I need to call the system function to open up several other matlab terminals and call a function I wrote that will have variable input. I have tried a lot of different methods but to no avail. This is basically what I'm trying to do.


    for i = 1:numberOfTerminals

    system('C:\MATLAB\R2009b\bin\matlab -r myFunction(var1*i,var2)')

    end

    I get errors saying the variables are undefined.

    I have tried

    ...

    system(['C:\MATLAB\R2009b\bin\matlab -r myFunction(', var1*i, var2, ')' ]);

    and

    system(['C:\MATLAB\R2009b\bin\matlab -r myFunction(%var1*i%,%var2%)' ]);

    etc...

    Thanks for the help!
     
  2. jcsd
  3. Aug 26, 2010 #2
    I solved it myself.

    For those interested, it can be done..

    str = ['C:\MATLAB\R2009b\bin\matlab -r Func(', num2str(var1), ',' ,num2str(var2) ',',num2str(var3), ')'];

    system(str)
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook