Calling Subroutine / Script file

9 ビュー (過去 30 日間)
Jay
Jay 2015 年 4 月 7 日
回答済み: Geoff Hayes 2015 年 4 月 7 日
If I want have a subroutine (.m) and want to run it in the body of a separate .m file (call it) how do I go about doing that.
The reason is it will allow different uses for the same code using different subroutines.

採用された回答

Geoff Hayes
Geoff Hayes 2015 年 4 月 7 日
Justin - if you have defined your subroutine as a function (or a script) then you can call it as is from within the body of the separate m file. For example, if the signature of your subroutine is something like
function [out] = mySubroutine(input)
is saved to a file named mySubroutine.m, then you can call this function from within the body of your other m file as
% do some stuff
% call mySubroutine
out = mySubroutine(input);
The above is an example only with one input and one output. I suspect that your function signature will be different.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by