Increase time with for loop
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Cam B
il 5 Apr 2022
Commentato: Walter Roberson
il 5 Apr 2022
I am trying to create a variable x that increases by 0.5, 16 times. Thus, at i =16, x it should be 8. I keep running into an error of 'Index exceeds the number of array elements. Index must not exceed 1.'
x=[];
x(1)=0;
for i=1:14
x=x(i)+0.5
end
0 Commenti
Risposta accettata
Chetan Bhavsar
il 5 Apr 2022
Modificato: Chetan Bhavsar
il 5 Apr 2022
You want like this or you want array?
x=0;
for i=1:16
x=x+0.5
end
y={};
x=0;
for i=1:16
x=x+0.5;
y = [y x];
end
y
3 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!