how to find out number of rows in particular matrix of the cell?

1 次查看(过去 30 天)
Suppose i have 1*2 cell as shown below
A B
[1 2] [1 2 ; 3 4]
how can i find out number of rows in each cell..in these example they are 1 and rsply. for A and B.

采纳的回答

Evan
Evan 2013-7-15
编辑:Evan 2013-7-15
>> a = {[1 2] [1 2; 3 4]}'
>> cellfun('size',a,1)
ans =
1 2
For more:
help cellfun
  2 个评论
siddhesh rane
siddhesh rane 2013-7-15
can you please tell me how can i get number of rows for only one matrix in cell .. for example i want no. of rows of second matrix..then answe r should be single digit i.e. 2.
Thanks in advance.

请先登录,再进行评论。

更多回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-7-15
out=cellfun(@(x) size(x,1),a)
  4 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2013-7-15
Sorry, my connection is very bad, I did not see your answer, I will remove mine
Evan
Evan 2013-7-15
编辑:Evan 2013-7-15
No worries, I often have the same problem. I just made that comment in order to clarify the difference between our answers (and to give you guys a chance to correct me in case I was mistaken :P). It wouldn't hurt to leave it up in order to have an example of how to use anonymous function handles with cellfun, especially since the list of available string arguments is pretty short and you oftentimes have to resort to function handles. I just wanted to clarify that, when available, the string arguments were best.

请先登录,再进行评论。

类别

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