SAVING DATA FROM A LOOP THAT DOES NOT START FROM ONE OR NOT POSITIVE INTEGERS OR LOGICALS
    1 vue (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    tomer polsky
 le 26 Nov 2017
  
    
    
    
    
    Commenté : Star Strider
      
      
 le 27 Nov 2017
            hello for exmplae i want to start a loop from zero like this :
{
for i=0:0.1:10
y(i)=i*10
end
}
but since i am not starting from one and the numbers are not positive integers i cant run the loop , what to do ?
0 commentaires
Réponse acceptée
  Star Strider
      
      
 le 26 Nov 2017
        If you want to use a for loop, you need to make a few changes:
v = 0:0.1:10;                       % Create Values As A Separate Vector
for i = 1:length(v)                 % Index Through The Length Of The Vector
    y(i)= v(i)*10;                  % Reference The Elements Of The Vector In The Calculation
end
4 commentaires
Plus de réponses (0)
Voir également
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!

