Problem with for loop
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jacob
el 25 de Feb. de 2014
Comentada: Jacob
el 26 de Feb. de 2014
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 comentarios
dpb
el 26 de Feb. de 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
el 26 de Feb. de 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.
Respuesta aceptada
Rick Rosson
el 26 de Feb. de 2014
Editada: Rick Rosson
el 26 de Feb. de 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;
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!