vector that displays [0 5 10 15]
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mahmoud Chawki
el 18 de Mayo de 2022
Comentada: Mahmoud Chawki
el 18 de Mayo de 2022
i want a for loops that displays the following vector
[0 5 10 15]
3 comentarios
Respuesta aceptada
Davide Masiello
el 18 de Mayo de 2022
Just be aware of the fact that you do not need to use a loop to do this
A = 0:5:15
That said, if you really must use a loop, then you could write
A = zeros(1,4);
for idx = 1:3
A(idx+1) = idx*5;
end
A
I strongly recommend going with the first option.
0 comentarios
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!