How change the constructor class in each loop?

3 ビュー (過去 30 日間)
Ana Reis
Ana Reis 2020 年 8 月 7 日
コメント済み: Ana Reis 2020 年 8 月 7 日
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 件のコメント
Geoff Hayes
Geoff Hayes 2020 年 8 月 7 日
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.
Ana Reis
Ana Reis 2020 年 8 月 7 日
Of course... So, essencialy my problem is in that loop. I need to use the constructor Class_AdvAnalysis in this loop, but the value Z (this.advanalysis.Z) needs to change in each loop... You can see this in Z = Z + stepZ. So, the constructor Class_AdvAnalysis changes their values each loop because the values of Z changes. I need to change the value Z in constructor Class_AdvAnalysis because the value pmax (in Class_Blast) depends of Z.
I don't know if I explained better...
Thank you for the help!

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by