Matlab-Matrix Tutorial
Selected Reading
- Matlab Matrix - Discussion
- Matlab Matrix - Useful Resources
- Matlab Matrix - Quick Guide
- Matlab-Matrix - Deletion Row & Coloumn
- Matlab-Matrix - Transpose
- Matlab-Matrix - Rank
- Matlab-Matrix - Trace
- Matlab-Matrix - Inverse
- Matlab-Matrix - Matrix Determinant
- Matlab-Matrix - Subtraction
- Matlab-Matrix - Addition
- Matlab-Matrix - Multiplication
- Matlab-Matrix - Working with Matrices
- Matlab-Matrix - Create Matrix
- Matlab-Matrix - Environment Setup
- Matlab-Matrix - Introduction
- Matlab-Matrix - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Matlab-Matrix - Deletion Row & Coloumn
Matlab-Matrix - Deletion of Row & Column
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 >>Advertisements