You can delete an entire row or column of a matrix by assigning an empty set of square braces [] to that row or column. Basically, [] denotes an empty array.
Example
For example, let us delete the fourth row of a, as shown below −
a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8]; a( 4 , : ) = []
Output
Here is the execution of above code in MATLAB
>> a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8] a( 4 , : ) = [] a = 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 a = 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 >>
The fourth row is deleted. It displays only three rows.
Example
Next, let us delete the fifth column of a, as shown below −
a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8] a(: , 5)=[]
Output
Let us see the execution of the above code in MATLAB −
>> a = [ 1 2 3 4 5; 2 3 4 5 6; 3 4 5 6 7; 4 5 6 7 8] a(: , 5)=[] a = 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 4 5 6 7 8 a = 1 2 3 4 2 3 4 5 3 4 5 6 4 5 6 7 >>