problems with a for loop within a switch statement

1 vue (au cours des 30 derniers jours)
Neo
Neo le 28 Juil 2015
Commenté : Walter Roberson le 30 Juil 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

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by