2

I wish to run a matlab m file from my windows 7 scheduler.

I can run a matlab m file that takes no parameters using the line below

-r my_matlab_function,exit

If I had a matlab function that was expecting a simple text parameter is there a way to also schedule the function to run via the windows 7 scheduler?

mHelpMe
  • 6,336
  • 24
  • 75
  • 150

1 Answers1

0
  1. You can use this:

    matlab -r "functionName input1 input2"
    

    Note that the inputs are interpreted as text. This is called command syntax. For example, issuing this command from a DOS window

    matlab -r "find [2 3]"
    

    produces

    ans =
         1     2     3     4     5
    

    because [2 3] is interpreted as an array of five chars, all of which are non-zero.

  2. You may also use function syntax:

    matlab -r "find([2 3])"
    

    which produces

    ans =
         1     2
    

    as would be expected.

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
  • I can't get it to work. So in the windows scheduler in the add arguements text box I have the following... -r myfunction myparameter,exit This does not work though in matlab the message was not enough parameters supplied. I'm trying to provide a string as a parameter – mHelpMe Jul 10 '15 at 13:09
  • I tried putting speach marks round "myfunction myparameter" but then it doesn't even launch matlab – mHelpMe Jul 10 '15 at 13:17
  • 1
    working now, so I just put myfunction('myparameter') and that was it, thanks for your help – mHelpMe Jul 10 '15 at 13:23