for loop, conditional operator
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Kashfia Mahin
il 16 Ago 2019
Modificato: Kashfia Mahin
il 19 Ago 2019
for k=1:length(kinetic);
if (delta(j)<=kinetic(k)) && (j==k)
filling_degree_regionI(j,k)=1/(2*pi).*(pi*(abra)/180-((rh/R).*cosd(kappa-kinetic(k))./cosd(alpha).*sind(abra)./cosd(shai-kinetic(k))))
filling_degree_regionI_new(1,k)=filling_degree_regionI(j,k);
end
end
end
for i=1:length(filling_degree_regionI_new);
if filling_degree_regionI(i) > 0
new_filling_degree_regionI(i)=filling_degree_regionI(i);
end
end
Here, I have to calculate filling degree using delta and kinetics. Kinetics[1*13] are calculated using delta[1*13]=[0:10:180]. To calculate filling degree[1*13], delta should be less than equal to kinetics and length of delta and kinetics should be same. and also filling degree can't be zero. but there is some error showing there.
Undefined function or variable 'filling_degree_regionI_new'.
i can't figure it out how to solve it.
0 Commenti
Risposta accettata
James Tursa
il 16 Ago 2019
Modificato: James Tursa
il 16 Ago 2019
You are creating the variable filling_degree_regionI_new inside a condition if statement. If the condition is never met, the variable filling_degree_regionI_new will not be created.
Maybe you could describe in words what variables you are starting with, what they contain, and what calculation you hope to do with them. We might be able to suggest a better way than what you are currently doing. E.g., what is the point of your double for-loops at the beginning if you don't take any action unless j==k? A single for-loop would suffice.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!