How to extract value from cell, then from matrix?

1 回表示 (過去 30 日間)
I G
I G 2019 年 1 月 16 日
編集済み: Andrei Bobrov 2019 年 1 月 16 日
I have data stored in p, as 1x41 cell. For me it is necessary to extract every value in cell, every 101x4 double as matrix and then to extract exact value from that matrix. My code is:
beta=1:0.1:5;
for i=1:length(beta)
a=p{[1,i]};
p0(i,1)=a(101,1);
p1(i,1)=a(101,2);
p2(i,1)=a(101,3);
p3(i,1)=a(101,4);
end
where length(beta)=41, because of that, p is 1x41 cell. Line a=p{[1,i]}; give me every matrix in dimensions 101x4. And then is necessary to store every value on position a(101,1) in p0. At the and p0 need to has dimension 41x1, and I got it, but with all the same values? p is not consisted of all the same values, so I cannot se my mistake? It is like for loop does not work.
p.jpg
p1.jpg

採用された回答

Andrei Bobrov
Andrei Bobrov 2019 年 1 月 16 日
編集済み: Andrei Bobrov 2019 年 1 月 16 日
B = cat(3,p{:});
p0_3 = num2cell(squeeze(B(end,:,:)).',1);
  1 件のコメント
Andrei Bobrov
Andrei Bobrov 2019 年 1 月 16 日
編集済み: Andrei Bobrov 2019 年 1 月 16 日
Here p0_3{1} is your p0, p0_3{2} is your p1 ,... p0_3{4} is your p3.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by