필터 지우기
필터 지우기

Go back inside a for loop

조회 수: 3 (최근 30일)
Jose Andrés
Jose Andrés 2015년 6월 22일
댓글: Jose Andrés 2015년 6월 25일
Hello everyone, I have created this function to show multiple dicom images and select one of them:
for z=1:size(read)
archive = read(z).name;
R3 = (dicomread(archive));
imshow(R3);
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
promptMessage = sprintf('Select the first image\nmanually');
titleBarCaption = 'Manual';
button = questdlg(promptMessage, titleBarCaption, ...
'Next', 'Select', 'Previous', 'Next');
if strcmpi(button, 'Previous')
¿¿??
end
if strcmpi(button, 'Select')
%I execute the code
end
end
My question is: how could I go back to the previous image when I push the "Previous" button without to break the for loop? What should I modify?
Thank you so much.

채택된 답변

Walter Roberson
Walter Roberson 2015년 6월 24일
z = 1;
while z <= length(read)
archive = read(z).name;
R3 = (dicomread(archive));
imshow(R3);
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
promptMessage = sprintf('Select the first image\nmanually');
titleBarCaption = 'Manual';
button = questdlg(promptMessage, titleBarCaption, ...
'Next', 'Select', 'Previous', 'Next');
if strcmpi(button, 'Previous')
z = z - 1;
continue;
end
if strcmpi(button, 'Next')
z = z + 1;
continue;
end
if strcmpi(button, 'Select')
%I execute the code
....
break; %leave while loop
end
end
  댓글 수: 2
Image Analyst
Image Analyst 2015년 6월 25일
read() is the name of a built-in function so he probably doesn't want to use that.
Jose Andrés
Jose Andrés 2015년 6월 25일
It works perfectly! Thank you so much again, you are amazing.
The real directory name is called "lee_archivos" because I'm spanish, and I had to change some names (like 'Next', 'Previous'...) here in my Question in order to make it clearer for everyone. Thank you anyway!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by