A third portion of the second week

>> A  = [1 2;3 4;5 6]
A =

   1   2
   3   4
   5   6

>> A(3,2)
ans =  6
A >> ( 2 , :)% of all the elements of the row or column 
ANS = . 3 . 4 
>> A (:, 2 ) 
ANS = 2 . 4 . 6 
>> A ([ . 1 . 3 ], :)% taking a first, three element row 
ANS = . 1 2 . 5 . 6

      



   
   
    

      
      
A >> (:, 2 ) = [ 0 ; 0 ; 0 ]% assigned to a second row A 
A = . 1 0 . 3 0 . 5 0 
>> A = [A, [ 10 ; . 11 ; 12 is ]];% then plus a
 >> a 
a = . 1 0 10 . 3 0 . 11 . 5 0 12 is 
>> a (:)% to all elements of a vector a form showing 
ANS = . 1 . 3 . 5 0 0 0 10 . 11 12 is

      
      
      

           
           
           

    
    
    
    
    
    
   
   
   

 

>> A 
A = . 1 0 10 . 3 0 . 11 . 5 0 12 is 
>> B = [ 36 12 is ; 23 is 0 ; 56 is 12 is ] 
B = 36 12 is 23 is 0 56 is 12 is 
>> C = [AB] 
C = . 1 0 10 36 12 is . 3 0 . 11 23 is 0 . 5 0 12 is 56 is 12 is 
>> C = [A; B]% AB ranks can be the same

           
           
           
   

      
       
      


                 
                  
                 



error: vertical dimensions mismatch (3x3 vs 3x2)
>> A = [1 0;3 0;5 0]
A =

   1   0
   3   0
   5   0

>> C = [A;B]
C =

    1    0
    3    0
    5    0
   36   12
   23    0
   56   12

>> A =[1;2;3]
A =

   1
   2
   3

>> C = [A;B]
error: vertical dimensions mismatch (3x1 vs 3x2)
>>
% As these two ways
 >> [A, B] 
ANS = . 1 36 12 is 2 23 is 0 . 3 56 is 12 is 
>> [AB] 
error: ' AB ' undefined near Line . 1 column 2 
>> [AB] 
ANS = . 1 36 12 is 2 23 is 0 . 3 56 is 12 is

          
           
          


          
           
          

Guess you like

Origin www.cnblogs.com/tingtin/p/12027987.html