How to share a variable from one method to another method?

classdef Sample
properties
a
b
end
methods
function f1 = form1(this)
f1 = 1 ./ this.a; % how to share this variable to other methods (in this example form2)?
end
function f2 = form2(this)
f2 = f1 .^ 2;
end
end
end

 採用された回答

Walter Roberson
Walter Roberson 2019 年 7 月 23 日

1 投票

Make a private property to hold it. Possibly make it a dependent property

5 件のコメント

madhan ravi
madhan ravi 2019 年 7 月 23 日
Thank you for the answer sir Walter. Could you show how it should look like?
Walter Roberson
Walter Roberson 2019 年 7 月 23 日
https://www.mathworks.com/matlabcentral/answers/351614-how-to-set-a-private-property
madhan ravi
madhan ravi 2019 年 7 月 24 日
Thank you once again sir Walter, definitely I need some practice. This field is relatively new to me. If possible could you structurise (meaning just number the topics), so that I could learn class (to master classes) step by step. For instance:
1) Properties
2)... and so on
If you could just tell the topics alone it would be a great help, I would manage it later on following your footsteps :).
Walter Roberson
Walter Roberson 2019 年 7 月 24 日
I have seldom created a class myself; some of the other regular volunteers have much much more experience with them.
madhan ravi
madhan ravi 2019 年 7 月 24 日
Oh ok sir Walter , thank you.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

製品

リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by