How to delete a row in MATLAB?

Delete a single row in matlab

In this article I will show simple examples to show how to delete a row in MATLAB? If we have a matrix of large order lets say m=rows=8, n=columns=10 and we want to delete a single row from it then look at the following example

delete a row in a matrix
delete a row in a matrix

Here, I have used a built in random function for generating a matrix with random entries of 8 rows and 10 columns..

Now, lets assume that I want to remove 5th row completely, then I will use the following command

A([5],:) = []

once you run this command on MATLAB, you will get the following result

delete a single row in matlab
delete a single row in matlab

Now it can be observed clearly that 5th row has been deleted

How to delete two rows in matlab

If you want to delete any two rows from above matrix A, say it 2, 3 then use the following syntax for it.

deleting two rows in matlab
deleting two rows in matlab

Also read here

https://eevibes.com/computing/how-to-take-integer-input-in-python/

How to take integer input in Python?

Leave a Reply

Your email address will not be published. Required fields are marked *