How to share a variable from one method to another method?
4 views (last 30 days)
Show older comments
madhan ravi
on 23 Jul 2019
Commented: madhan ravi
on 24 Jul 2019
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
0 Comments
Accepted Answer
Walter Roberson
on 23 Jul 2019
Make a private property to hold it. Possibly make it a dependent property
5 Comments
Walter Roberson
on 24 Jul 2019
I have seldom created a class myself; some of the other regular volunteers have much much more experience with them.
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!