Backtrack iteration for loop

13 ビュー (過去 30 日間)
Gonzalo Guerrero
Gonzalo Guerrero 2022 年 5 月 31 日
コメント済み: Gonzalo Guerrero 2022 年 6 月 1 日
Hi,
I am running a code where I plot images in a 2 for loops. I got 3 different buttons that allows me to go to the iteration "Next", analyse the image or go back to the previous image "previous" iteration. However, in this case I got a an issue. I am trying to go back an iteration(i.e. if n=3 and nn=2 or 3) I want to go one backwards on that for loop. However if nn=1. I need to go one back in the n for loop and the last of the nn. at the moment It does't do that. This is a part of the code, I could provide the whole of it if needed.
for n= 1:length(DigMark) aproxx(1:100)
for nn=1:length(Mucles) aprox(1:3)
message= sprintf('Select one of the following:');
titleBarCaption = 'Manual';
Button = questdlg(message, titleBarCaption, ...
'Previous','Analyses','Next', 'Analyses');
if strcmpi(Button, 'Previous') && nn == 1
s=s-1 ;
n = n - 1;
nn= length(EMG);
keyboard
outputTable(end, :)=[];
close(figu);
elseif strcmpi(Button, 'Previous') && nn > 1
s=s-1 ;
nn= nn-1;
keyboard
outputTable(end, :)=[];
close(figu);
continue;
end
end
end
Thank you for your help! :D

採用された回答

AndresVar
AndresVar 2022 年 5 月 31 日
編集済み: AndresVar 2022 年 5 月 31 日
i think matlab for loop doesn't allow changing the iterator, you can use while loop instead.
  1 件のコメント
Gonzalo Guerrero
Gonzalo Guerrero 2022 年 6 月 1 日
Thank you!
I was trying to avoid the while loop(since I am not good with it), but other threads have the answer!
I solved the problem with the while loop now! :D

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by