フィルターのクリア

how we can control the length of each elemnts in a cell array?

3 ビュー (過去 30 日間)
saharsahar
saharsahar 2012 年 2 月 26 日
Dea All, I'm wondering how we can control of the length(size) of each elemnt in a cell array(Since each elemnt is a matrix itself) .
Thanks

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 2 月 26 日
C - your cell array
out = cellfun(@size,C,'un',0)
  1 件のコメント
Jan
Jan 2012 年 2 月 26 日
Or, as usual: "cellfun('size', C, 2)" to get a vector of the lengths of the 2nd dimensions.

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2012 年 2 月 26 日
Not sure I understand. You control what goes in so of course you control the length of it because you know what you put in. For example in this cell array with 2 cells, I put a 1x4 array into the first cell, and I put a 3x8 array into the second cell:
ca{1} = rand(1,4)
ca{2} = rand(3,8)
I controlled the lengths of each individual cell (4, and 3*8=24) because I controlled what I put in there, and I controlled the length of the cell array (2) because I created 2 cells. Am I missing something here (about why you're confused)?
  2 件のコメント
saharsahar
saharsahar 2012 年 2 月 27 日
I understand what u are saying, but sometimes it is increasing by loop and I don't know the final size. However I got my answer from "andrei".
Thanks anyway.
Image Analyst
Image Analyst 2012 年 2 月 28 日
But you got an answer to something you didn't ask. They showed you how to DETERMINE (or "find out") the size of your cell, not CONTROL it. There is a difference in definition between determine and control. I showed you how to control the size (like you asked) whereas they showed you how to determine what you already have (i.e. find out what you have already in existence but not how to specify or control the size in the first place).

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by