How to exclude unwanted numbers in a cell?

2 次查看(过去 30 天)
Hey MATLAB users,
I've got a problem! If we have: a={1,17951,1,0 ; 1,20345,1,0 ; 1,22950,1,0 ; 1,25360,1,0};
and I want to exclude 1,...,1,0 which are the same in all and as a result have cell array b as b = {17951 ; 20345 ; 22950 ; 25360}; how can I do that?
Thank you so much for your hint in advance.
Mehdi :)

采纳的回答

Wayne King
Wayne King 2011-11-11
a={1,17951,1,0 ; 1,20345,1,0 ; 1,22950,1,0 ; 1,25360,1,0};
b = cellfun(@(x) x(x>1),a,'uni',0);
b(cellfun(@isempty,b))=[];
  2 个评论
Wayne King
Wayne King 2011-11-11
I wasn't sure if when you say always the same you mean that they are always 0 and 1.
M G
M G 2011-11-11
Yes, they are always the same values. Thanks a lot.

请先登录,再进行评论。

更多回答(0 个)

类别

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