How can I label a vector?
    3 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Sam
 am 29 Nov. 2018
  
    
    
    
    
    Bearbeitet: madhan ravi
      
      
 am 29 Nov. 2018
            Hello,
I have a vector of 10 random numbers. I want to label the first 5 elements in the vector as '1'. I want to label the last 5 elements in the vector as '0'. How can I do this?
Thanks!
0 Kommentare
Akzeptierte Antwort
  Star Strider
      
      
 am 29 Nov. 2018
        Try this: 
L = [ones(1,5) zeros(1,5)];                     % Labels
V = rand(1,10);                                 % Vector
Out = [L; V]
producing: 
Out =
  Columns 1 through 8
            1            1            1            1            1            0            0            0
     0.060019      0.86675      0.63119      0.35507        0.997      0.22417      0.65245      0.60499
  Columns 9 through 10
            0            0
      0.38725      0.14219
0 Kommentare
Weitere Antworten (1)
  madhan ravi
      
      
 am 29 Nov. 2018
        
      Bearbeitet: madhan ravi
      
      
 am 29 Nov. 2018
  
      x(1:5)=1; % where x is your random  vector
x(end-4:end)=0;
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


