필터 지우기
필터 지우기

How to delete the row from cell array?

조회 수: 157 (최근 30일)
siddhesh rane
siddhesh rane 2013년 7월 10일
댓글: Kris Hoffman 2022년 7월 5일
I have a cell arraywhich has 10*6 matrix in it. How can I delete a row from the matrix? thanks in advance.

채택된 답변

Matt J
Matt J 2013년 7월 10일
Is this what you want:
>> A(1:2)={rand(10,6)}
A =
[10x6 double] [10x6 double]
>> row=2; A{1}(2,:)=[] %delete 1 row from 1 cell
A =
[9x6 double] [10x6 double]
  댓글 수: 4
Stephen23
Stephen23 2018년 9월 28일
@Ram: you will have to use a loop.
Matt J
Matt J 2018년 9월 28일
As Stephen says, you will have to use a loop, but you can also hide the loop with cellfun,
cellfun(@(c) c(1:800), yourCell, 'uni',0 )

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 7월 10일
row=2
A(row,:)=[]
  댓글 수: 6
Tong Zhao
Tong Zhao 2022년 6월 16일
Thanks from 2022
Kris Hoffman
Kris Hoffman 2022년 7월 5일
Thanks from 2026

댓글을 달려면 로그인하십시오.


John
John 2013년 7월 10일
편집: John 2013년 7월 10일
You can index out the rows like any standard array (the following code removes the second row):
x = {1 2 3; 4 5 6; 7 8 9}
x =
[1] [2] [3]
[4] [5] [6]
[7] [8] [9]
y = x([1 3],:)
y =
[1] [2] [3]
[7] [8] [9]
  댓글 수: 3
John
John 2013년 7월 10일
Ok I think I understand, you have a cell array that looks like the following:
A = {rand(5), 1}
A =
[5x5 double] [1]
You want to remove a row from the matrix in the first element of A. You can do the following:
A{1} = A{1}([1 2 4 5],1);
(this will remove the third row). Alternatively you can use Azzi Abdelmalek's method shown below:
A{1}(3,:) = []
I think this is what you are looking for.
siddhesh rane
siddhesh rane 2013년 7월 10일
thank you!! :)

댓글을 달려면 로그인하십시오.


siddhesh rane
siddhesh rane 2013년 7월 10일
[A] [B] [C]
suppose i have 1*3 cell as shown above and A is a matrix of dimensions 3*3 and I want to delete second row of the A matrix. How should i do it?

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by