Calling multiple cell elements at once

3 ビュー (過去 30 日間)
carlos Uribe
carlos Uribe 2012 年 11 月 17 日
Hello,
I have a cell something like
A=
[1x3 double] [1x3 double] [1x3 double] [1x3 double]
Is it possible to call the first position of each vector at once? Something like
A{:}(1)
  2 件のコメント
Matt J
Matt J 2012 年 11 月 17 日
Since your A{i} are all the same size and numeric type, it is puzzling why you would maintain it in cell form, as opposed to a 4x3 matrix for example.
carlos Uribe
carlos Uribe 2012 年 11 月 19 日
Hi Matt, thanks for your reply...Yes I guess I chose a bad example but I just chose a bad example for what I want to do...not necessarily all of them will be the same size still I would like to call the first position for different purposes.

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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 17 日
B=cell2mat(A);
out=B(1:3:end)

その他の回答 (1 件)

per isakson
per isakson 2012 年 11 月 17 日
Not with plain indexing. This one-liner does it
r = cellfun( @(v) v(1), A )
However, ...

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by