How change the constructor class in each loop?
3 views (last 30 days)
Show older comments
Hey guys,
Well, I am developmenting a code that can calculate some parameters about pressure in a structure.
So, I have 4 constructor class and 3 class with methods of calculus. My problem is in the class Class_Advanced. In this class, I need to change the constructor in each loop, but the values not changes. The values in constructor needs to change because they influence another class, in this case, Class_Blast.
Of course my project is bigger than it, but I tried to simplify this project to ask you.
All classes is atached.
Next, my loop:
function this = Relation_Z...
(this, tnt, analysis, advanalysis, blast)
this.tnt = tnt;
this.analysis = analysis;
this.advanalysis = advanalysis;
this.blast = blast;
Z = this.advanalysis.Z;
W_final = this.advanalysis.W;
% ----------------------------------------------------------- %
% Initial parameters
N = 100; % Number of steps
stepZ = (40 - Z) / N; % Step Z
% ----------------------------------------------------------- %
% Calculating the curve
for i = 1 : N
pmax = this.blast.pmax;
this.matrix_DispZ(i,1) = Z;
this.matrix_DispZ(i,2) = pmax;
Z = Z + stepZ;
% Changind in constructor mode
Class_AdvAnalysis(Z, 1, W_final, N);
end
end
2 Comments
Geoff Hayes
on 7 Aug 2020
Ana - please clarify what you mean by My problem is in the class Class_Advanced...In this class, I need to change the constructor in each loop, but the values not changes. Do you mean that you want to use a different class (constructor) on each iteation of the loop? Or a different constructor for the class? It isn't clear from the above code and the comment "Changind in constructor mode" what you are attempting to do.
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!