How to loop through and create an nx2 vector?
    2 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Bobalob
 am 1 Mär. 2015
  
    
    
    
    
    Bearbeitet: per isakson
      
      
 am 1 Mär. 2015
            Hi there,
I have a function 'myfunction' that takes a single number as an input and returns a 1x2 vector. How do I perform a loop such that I can create an nx2 vector for multiple input values. I'm trying this but seem to be doing something wrong.
for i = 1:n
output(i) = [myfunction(i)];
end
thanks!
0 Kommentare
Akzeptierte Antwort
  per isakson
      
      
 am 1 Mär. 2015
        
      Bearbeitet: per isakson
      
      
 am 1 Mär. 2015
  
      Try
    output = nan( 10, 2 );
    for ii = 1:10
        output(ii,:) = myfunction(ii);
    end
and read
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

