Select particular elements from a cell array to form a matrix (double type)

1 回表示 (過去 30 日間)
Meng Li
Meng Li 2021 年 7 月 28 日
コメント済み: Meng Li 2021 年 7 月 28 日
Dear all,
I have created a 2 by 2 cell array named "results". Each cell has multiple matrices or other types. I want to select the elements in the 17th row and the 1st column from every matrix of "endo_simul" in every cell "results{,}" and then form a matrix. Could anyone help me with it?
Thank you!

採用された回答

Chunru
Chunru 2021 年 7 月 28 日
x = zeros(size(results));
for i=1:size(results, 1)
for j=1:size(results, 2)
x(i,j) = results{i,j}.endo_simul(17, 1);
end
end
  1 件のコメント
Meng Li
Meng Li 2021 年 7 月 28 日
I have tried your code and it works perfectly. Thank you very much!

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

その他の回答 (1 件)

Stephen23
Stephen23 2021 年 7 月 28 日
Simply:
fun = @(x) x.endo_simul(17,1);
out = cellfun(fun,results)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by