for loop with 3 variables
Afficher commentaires plus anciens
xvirtual = [250:10:300]
for jj = 1:length(xvirtual)
for j = 50000:50100 %:length(Z(:,1))
for i = xvirtual(jj):length(xq(1,:))-1
V(j,i) = pointdistance*(Z(j,i)-Zq(i));
end
Volume(j) = sum(V(j,:) ,'omitnan'); % virtual overtopping volumes in time
end
Vis(jj,:) = Volume;
end
Hi hope someone can help me with this code. I want to loop through time=j, the space =i and different xvirtual levels = jj. As result I get Vis, however this result contains the same volumes for all rows. So probably it is only calculating for the first xvirtual=250. How can I calculate for the other values of xvirtual?
4 commentaires
Adam
le 4 Fév 2019
Why are you indexing j from 50000? This will create V and Volume variables vastly bigger than required, with 0s form the previous 49999 elements/rows.
ceycey
le 4 Fév 2019
Cris LaPierre
le 4 Fév 2019
Modifié(e) : Cris LaPierre
le 4 Fév 2019
Hard to say without knowing more about the other variable: pointdistance, Z, Zq and xq. Can you attach a mat file containing them? Or at least provide info on their size?
ceycey
le 5 Fév 2019
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!