problems with a for loop within a switch statement

1 Ansicht (letzte 30 Tage)
Neo
Neo am 28 Jul. 2015
Kommentiert: Walter Roberson am 30 Jul. 2015
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 29 Jul. 2015
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 Kommentare
Neo
Neo am 30 Jul. 2015
I'm actually referring to the former a. That is what I wanted.
Walter Roberson
Walter Roberson am 30 Jul. 2015
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by