problems with a for loop within a switch statement
1 次查看(过去 30 天)
显示 更早的评论
I am creating a code where there is a for loop within a switch statement. I want the switch statement in there because I want to evaluate an expression, (SSIM), then for each time it is evaluated I want it to pick out values between 0 to 1 or from -1 to 1. But I am having trouble, and am not sure, how to set this up. Here is what I have so far:
ref = picture2
A = picture1
subplot(1,2,1); imshow(ref); title('Mode 1');
subplot(1,2,2); imshow(A); title('Mode 2');
fprintf('The SSIM value is %0.4f.\n',ssimval);
switch [ssimval, ssimmap] = ssim(A,ref);
case i := 1:
for i from 0 to 1 do
a := <i;
fprintf('The SSIM value is %0.4f.\n',ssimval);
figure, imshow(ssimmap,[]);
title(sprintf('ssim Index Map - Mean ssim Value is %0.4f,',ssimval));
otherwise
title(sprintf('ssim Index Map - Mean ssim Value is %0.4f does not fit within criteria,',ssimval));
end
Any suggestions? Thanks to all and to all a good night (except for the best Answerer :p) - Neo
0 个评论
采纳的回答
Walter Roberson
2015-7-29
http://www.mathworks.com/help/matlab/ref/for.html (and notice you must end the loop)
I do not know what the intention is for your line
a := <i;
Perhaps you wanted assignment, but the "<i" part is a mystery. "<" looks like one of the relational operators but those require a value on each side of the symbol.
6 个评论
Walter Roberson
2015-7-30
i(i >=0 & i <= 1) is an example of logical indexing. You define a test for the values you want to keep, resulting in a vector of true/false values. Indexing something with true and false selects the elements where the index is true.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!