How to store loop value in array?

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 10 de Mayo de 2020
Editada: Ameer Hamza el 10 de Mayo de 2020
You need to use an array to store all the values. If values are scalar or vectors of constant length, then you can use simple arrays. If, in each iteration, the result is of variable length, then you will need to use cell arrays. For example
A = zeros(1, 10)
for i = 2:10
A(i) = A(i-1) + 1;
end

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 10 de Mayo de 2020

Editada:

el 10 de Mayo de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by