How to store 4 outputs in 1 variable?
    4 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Sam
 am 25 Jan. 2018
  
    
    
    
    
    Kommentiert: Stephen23
      
      
 am 25 Jan. 2018
            Hello,
I can't seem to find the solution for my problem. I created a function which gives 4 outputs. I call the function in the command window:
x = rand([50,1])
a([1,2,3,4])= descriptives(b)
descriptives gives the max,min,mean and std for a random vector. I want to store these 4 values into a vector, but I don't know how to do it...
Thanks
0 Kommentare
Akzeptierte Antwort
  Star Strider
      
      
 am 25 Jan. 2018
        Try this:
[a(1),a(2),a(3),a(4)] = descriptives(b)
This assumes ‘descriptives’ returns 4 separate scalar values.
1 Kommentar
  Stephen23
      
      
 am 25 Jan. 2018
				More robust with preallocation:
a = zeros(1,4);
[a(1),a(2),a(3),a(4)] = descriptives(b)
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Performance and Memory 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!


