Problem with for loop
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
for i = 1:19
P(i) = [2.8*10^-4:0.1*10^-4:4.2*10^-4]
I cannot figure out how to fix my loop
3 Commenti
dpb
il 26 Feb 2014
From what you're showing, you don't need (or want) a loop at all.
doc colon
and read the "Getting Started" section in help on manipulating arrays in Matlab to begin to get the picture.
per isakson
il 26 Feb 2014
P = [2.8e-4:1e-5:4.2e-4];
and
P = [2.8*10^-4:0.1*10^-4:4.2*10^-4];
return identical results.
Risposta accettata
Rick Rosson
il 26 Feb 2014
Modificato: Rick Rosson
il 26 Feb 2014
No need for a for loop, no need for square brackets. Also, might as well pull common scale factor out using distributive property:
P = (2.8:0.1:4.2)*1e-4;
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!