Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Deleting a row in 3 dimensional matrix

Subject: Deleting a row in 3 dimensional matrix

From: Saurabh

Date: 3 Dec, 2010 20:44:05

Message: 1 of 4

Hi All,

I have 3 dimensional matrix points(:,:,:) . I want to delete a row from the 2 dimensional matrix which is represented by first two dimensions.

For example if I have a 10x20x30 matrix, then how to delete a row referenced by points(2,:,3) , i.e. the second row of the 2-d matrix which belongs has the third dimension as 3.

Subject: Deleting a row in 3 dimensional matrix

From: Sean de

Date: 3 Dec, 2010 20:52:04

Message: 2 of 4

"Saurabh " <sausax2000@yaho.com> wrote in message <idbkql$sjc$1@fred.mathworks.com>...
> Hi All,
>
> I have 3 dimensional matrix points(:,:,:) . I want to delete a row from the 2 dimensional matrix which is represented by first two dimensions.
>
> For example if I have a 10x20x30 matrix, then how to delete a row referenced by points(2,:,3) , i.e. the second row of the 2-d matrix which belongs has the third dimension as 3.

You can't. What would you expect to be there after? The matrix has to maintain a box shape with not holes cut through it.

Subject: Deleting a row in 3 dimensional matrix

From: Walter Roberson

Date: 3 Dec, 2010 20:55:30

Message: 3 of 4

On 10-12-03 02:44 PM, Saurabh wrote:

> I have 3 dimensional matrix points(:,:,:) . I want to delete a row from
> the 2 dimensional matrix which is represented by first two dimensions.
> For example if I have a 10x20x30 matrix, then how to delete a row
> referenced by points(2,:,3) , i.e. the second row of the 2-d matrix
> which belongs has the third dimension as 3.

In a 3D matrix, if you want the result to remain a 3D matrix instead of
collapsing to a column vector, you would have to delete an entire plane rather
than just one row.

points(2,:,3) = [];

would have the problem that points([1 3:10],:,:) would then be a different
size than points(2,:,3), and that would not be allowed.

The 2D equivalent of your question would be to delete a single element from a
2D matrix without affecting any of the other rows or columns of the matrix...
can't be done.

You could overwrite the section with NaN; depending on the calculations you
are doing, that works even better than actual erasing.-

Subject: Deleting a row in 3 dimensional matrix

From: Saurabh

Date: 3 Dec, 2010 22:22:05

Message: 4 of 4

Thanks Walter, 2D example was enlightening.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us