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

4 views (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 23 Jul 2019
Make a private property to hold it. Possibly make it a dependent property
  5 Comments
Walter Roberson
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!