1. Operation instructions
Take a certain row: Ki = K( i , : );
Take a certain column: Kj = K( : , j );
Take a certain number of rows: Kij = K( i : j , : );
Take a certain number of columns:Kij = K( : , i : j );
i
andj
represent the number of rows and columns
2. Example analysis
For example, matrix K=[1 2 3; 4 5 6 ; 7 8 9], three rows and three columns.
K =[1 2 3 ;
4 5 6 ;
7 8 9];
%取K第一行
K1=K( 1 , : );
%取K第二列
K2=K( : , 2 );
%取第二三行
K23 = K( 2 : 3 , : );
%取K第一二列
K12 = K( : , 1 : 2 );
The returned result is:
>> K1
K1 =
1 2 3
>> K2
K2 =
2
5
8
>> K23
K23 =
4 5 6
7 8 9
>> K12
K12 =
1 2
4 5
7 8