Multiple functions inside one .m file

14 ビュー (過去 30 日間)
Martin Jensen
Martin Jensen 2020 年 11 月 3 日
コメント済み: Martin Jensen 2020 年 11 月 4 日
I am trying to add multiple functions inside one master function. For example I want the follow three functions inside one file/function so that I can easily edit them with out changing between multiple files
function [Gc] = transferfunction_Gc
s = tf('s');
Gct=1;
Gcn=s*(s+1)^2;
Gc=Gct/Gcn;
end
function [Gp] = transferfunction_Gp
s = tf('s');
Gpt=1;
Gpn=s*(s+1)^2;
Gp=Gpt/Gpn;
end
function [H1] = transferfunction_H1
s = tf('s');
H1t=1;
H1n=s*(s+1)^2;
H1=H1t/H1n;
end
Is there anyway this is possible?
  1 件のコメント
Rik
Rik 2020 年 11 月 3 日
You can put them in one function file (or even a script file with a reasonably new release). How do you want to use them? In a single master function, or in a single script? If the answer is not one of those options you can't do it.

サインインしてコメントする。

採用された回答

Jeff Miller
Jeff Miller 2020 年 11 月 3 日
Try the method involving static classes, as explained here by per isakson
  1 件のコメント
Martin Jensen
Martin Jensen 2020 年 11 月 4 日
Thank you, this worked.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by