Finding number of answers from for loop that fits criteria
1 回表示 (過去 30 日間)
古いコメントを表示
Cside
2019 年 11 月 28 日
コメント済み: JESUS DAVID ARIZA ROYETH
2019 年 11 月 28 日
Hi, currently I have a code that looks something like this and would like the answer to be the number of p that fit the criteria of < 0.05. However, it does not seem to work as the for loop does not collate the p values that runs through the loop i.e. the answer will be over-written with each loop. Is there a way I can better write this? Thank you!
for n = 1:30
p = anova1(A(n,:), locations', 'off');
end
ans = sum(p<0.05)
0 件のコメント
採用された回答
JESUS DAVID ARIZA ROYETH
2019 年 11 月 28 日
solution:
p=zeros(1,30);
for n = 1:30
p(n) = anova1(A(n,:), locations', 'off');
end
anss = sum(p<0.05)
3 件のコメント
JESUS DAVID ARIZA ROYETH
2019 年 11 月 28 日
Maybe it's really 0, try this one:
anss=0;
for n = 1:30
p= anova1(A(n,:), locations', 'off');
anss=anss+(p<0.05);
end
disp(anss)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!