repeated for-looping without telling matlab to repeat loop error
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Alyna
am 15 Dez. 2014
Beantwortet: Image Analyst
am 15 Dez. 2014
Here is my code:
for m = 1:num_spans
h1 = plot(Repetitions{:,m}); % plot the rep
repcycle = sprintf('Rep %d',m);
title(repcycle) % put title on graph to show user the rep
[x, y] = ginput(2);
xlabel('Time (s)')
ylabel('Amplitude (mV)')
close figure 1
choice = input('Do you want to keep these start/stop times? (1 = yes, 2 = no): ');
while choice == 2
h1 = plot(Repetitions{:,m});
[x, y] = ginput(2);
repcycle = sprintf('Rep %d',m);
title(repcycle) % put title on graph to show user the rep
choice = input('Do you want to keep these start/stop times? (1 = yes, 2 = no): ');
end
xpoints(:,m) = [x(1,1),x(2,1)];
end
for some reason when running this code, MATLAB continuously repeats this for-loop without any code telling it to repeat. Why is this happening and how can I make it stop?
1 Kommentar
Image Analyst
am 15 Dez. 2014
Which loop: the "for" or the "while"? And what is the value of num_spans? And, do you know how to step through your code using the debugger?
Akzeptierte Antwort
Image Analyst
am 15 Dez. 2014
Instead of input(), try this:
promptMessage = sprintf('Do you want to keep these start/stop times?');
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Yes', 'No', 'Yes');
if strcmpi(button, 'No')
break;
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Exploration finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!