call a matlab script in a script

后端 未结 4 1964
没有蜡笔的小新
没有蜡笔的小新 2021-02-13 03:20

I have two matlab script files .m (not function files) and if I want to call another script in my current script, which command should I use? Thank you.

4条回答
  •  一整个雨季
    2021-02-13 03:47

    If you want to pass parameters to it, enclose them in parentheses.

    angle=.78; bias=.001; 
    myOtherScript(angle, bias)
    

    If you want to return parameters from it, do it like this:

    adjustedAngle = myOtherScript(angle, bias);
    

    Or multiple return values:

    [status adjustedAngle] = myOtherScript(angle, bias);
    

    If you don't want the return values immediately reflected to the command window (maybe this call is in a big loop and you're going to plot all the values later), be sure to put a semicolon after the call statement.

提交回复
热议问题