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!