How to select multiple elements from cell containing multiple double's

2 ビュー (過去 30 日間)
Michiel
Michiel 2014 年 8 月 16 日
コメント済み: Michiel 2014 年 8 月 16 日
Hi,
I have a cell variable 'var' containg 19 [4x4 double] matrices. I want to select the first element (ie (1,1)) of every matrix in this cell. If you want to select an element from just one matrix it can be easily achieve using var{1}(1,1). However, if I want to select this element from all matrices, matlab gives an error. I've tried: - [var{:}(1,1)] which leads to error 'bad cell reference operation'.
Anyone have a solution? Btw, I know I can get it by writing a for loop, but surely there must be a more elegant way?

採用された回答

Michael Haderlein
Michael Haderlein 2014 年 8 月 16 日
cellfun(@(x) x(1,1),var)

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by