Increase time with for loop
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Chetan Bhavsar
le 5 Avr 2022
Modifié(e) : Chetan Bhavsar
le 5 Avr 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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!