How to use the "switch ......case....end" syntax when the case number is variant, ?
1 view (last 30 days)
Show older comments
Dear all:
My subject number would change from time to time. I could find out the number during the images processing, and label the subject one by one. According to the labeled number, I could find my subject one by one by a for loop syntax like that:
for n=1:MaxmiumLabeledNumber
for l=1:47 (the maxmium slice number of images)
for p=1:512
for q=1:512
if images(p,q,l)=n
......
end
end
end
end
end
If it can be changed in "switch...case...end" syntex, the processing speed would be increased by MaxmiumLabeledNumber.
for l=1:47
for p=1:512
for q=1:512
switch images(p,q,l)
case 1
......
case 2
......
case 3
......
......
case MaxmiumLabel
......
end
end
end
end
The question is how to use it by auto adapted list of cases
Thank you very much for your kindness.
Trison
1 Comment
Answers (1)
Jan
on 12 Mar 2012
You cannot use hard coded SWITCH/CASE blocks for a dynamically changing list of CASE statements.
Is the outer loop for n really needed? Would something like this work:
for l=1:47
for p=1:512
for q=1:512
n = images(p,q,l);
......
end
end
end
?
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!