How to Assign These Values to This Struct?

1 回表示 (過去 30 日間)
Rightia Rollmann
Rightia Rollmann 2017 年 3 月 3 日
コメント済み: KSSV 2017 年 3 月 3 日
As an example, I want to dynamically assign four output arguments of ttest function to four field of struct A, but I get the error: “Subscripted assignment dimension mismatch.” What is the solution?
for i = 1:5
[A.B.h(i,1), A.B.p(i,1), A.B.ci(i,1), A.B.stats(i,1)] = ttest(X1, X2);
end;

採用された回答

KSSV
KSSV 2017 年 3 月 3 日
Try like this:
for i = 1:5
[out1,out2,out3,out4] =ttest(X1, X2);
A.B.h(i,1) = out1 ;
A.B.p(i,1)= out2 ;
A.B.ci(i,1) = out3 ;
A.B.stats(i,1) =out4 ;
end
  4 件のコメント
Rightia Rollmann
Rightia Rollmann 2017 年 3 月 3 日
it is a built-in function of MATLAB. Like here
KSSV
KSSV 2017 年 3 月 3 日
Then it is better to follow as what I suggested.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by