for loop with 3 variables
Mostra commenti meno recenti
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 Commenti
Adam
il 4 Feb 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
il 4 Feb 2019
Cris LaPierre
il 4 Feb 2019
Modificato: Cris LaPierre
il 4 Feb 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
il 5 Feb 2019
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!