How change the constructor class in each loop?

1 visualización (últimos 30 días)
Ana Reis
Ana Reis el 7 de Ag. de 2020
Comentada: Ana Reis el 7 de Ag. de 2020
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 comentarios
Geoff Hayes
Geoff Hayes el 7 de Ag. de 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.
Ana Reis
Ana Reis el 7 de Ag. de 2020
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!

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by