How to store loop value in array?
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Vinay Sharma
il 10 Mag 2020
Modificato: Ameer Hamza
il 10 Mag 2020
For ....
A=A+1;
End
%how can i store value A in array
0 Commenti
Risposta accettata
Ameer Hamza
il 10 Mag 2020
Modificato: Ameer Hamza
il 10 Mag 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
See the first example here: https://www.mathworks.com/help/matlab/ref/for.html
0 Commenti
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!