how to solve this code ??

1 vue (au cours des 30 derniers jours)
yasmeen hadadd
yasmeen hadadd le 26 Sep 2016
Commenté : yasmeen hadadd le 26 Sep 2016
Hello;
how i can change this code to get the specific output
clc;clear all;
for i=1:10;
a=i+5;
end
the final value of a =15 , i need a =[ 6 7 8 9 10 11 12 13 14 15];
thanks

Réponse acceptée

Walter Roberson
Walter Roberson le 26 Sep 2016
You are overwriting all of a each iteration of the loop. You need to instead only assign to one particular vector element:
a(i) = i + 5;
  1 commentaire
yasmeen hadadd
yasmeen hadadd le 26 Sep 2016
thanks alot

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements 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!

Translated by