Problem with Max function in a if loop
古いコメントを表示
So, basically my max function at the end gives me a random number and does not apply my if and else if constraint :/
for i = 1:B
JIM{i} = find(REG{1,i} > 0.5);
end
Ans = [JIM;REG;COEFF];%Merge REG and Coeff together so that we can keep an eye on variables name!
for i = 1:B
for j = 1:C
D{i} = find(Ans{3,i}.tStat(:).^2 > 3.8416);
end
end
BLOG = [Ans;D];
for i = 1:B
SIZE{i} = size(BLOG{4,i});
end
for i = 1:B
if BLOG{1,i} ==1
elseif SIZE{1,i}(1,1) ==test.NumCoefficients
H = max(BLOG{2,:});
end
end
end
4 件のコメント
Walter Roberson
2013 年 5 月 30 日
There is no such thing as an "if loop". There are "for loop" and "while loop" and "if statement"
Walter Roberson
2013 年 5 月 30 日
Why would you expect max() of a value you pass in, to apply an "if constraint" ? max() is just going to find the maximum.
Where do you initialize H ? What if elseif does not happen to be true anywhere, then what are you expecting H to be set to afterwards? Are you aware that it looks like you can overwrite H on different iterations of the "for i" loop ?
Walter Roberson
2013 年 5 月 30 日
Please show size(BLOG) class(BLOG{2,1}) size(BLOG{2,1})
採用された回答
その他の回答 (2 件)
Simon
2013 年 5 月 30 日
0 投票
2 件のコメント
Walter Roberson
2013 年 5 月 30 日
I can't tell what the algorithm is intended to be.
I can say, though, that it seems confusing to package things up into Ans and BLOG and then pull out specific elements of those that appear to be intended to correspond to the parts that were packaged together. Instead of BLOG{2,:} why not refer to D{:} ?
Simon
2013 年 5 月 31 日
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!