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 日

2 投票

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 件のコメント

siddhesh rane
siddhesh rane 2013 年 7 月 10 日
exactly..thanks a lot !!
Ram
Ram 2018 年 9 月 28 日
@matt J how to delete a each matrix with certian cell number. for example, cell matrix is [999*1][999*1][989*1][999*1][999*1]...[998*1]. Now from each cell matrix, i want to delete from 800 to end of cell matrix. how can i do that?
I tried cell{:,1}(801:end,1) = []; but getting error as A null assignment can have only one non-colon index. thanks in advance
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 日

9 投票

row=2
A(row,:)=[]

6 件のコメント

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?
Will it be
A(1,1)(2,:) = []
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 7 月 10 日
row=2;
out=cellfun(@(x) x(setdiff(1:10,row),:),A,'un',0)
Shihao Wang
Shihao Wang 2018 年 4 月 26 日
Thanks from 2018
Mehdi Maadir
Mehdi Maadir 2021 年 7 月 9 日
Thanks from 2021
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 日

2 投票

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 件のコメント

siddhesh rane
siddhesh rane 2013 年 7 月 10 日
This will delete row of matrix in a cell. I have many elements in each matrix (in this case theres only one element) I want to delete a row from those matrices.
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 日

0 投票

[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?

カテゴリ

ヘルプ センター および File Exchange で MATLAB についてさらに検索

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by