Slider Code Only Displaying One Image
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I want to scroll through 3 plots with the slider inside GUIDE.
But I'm only getting one plot and not 3. Here is the code:
%Data For Slider
handles.x = 1:100;
handles.y = 1:100;
axes = handles.axes1;
set(handles.slider1,'Min',1,'Max',3,'SliderStep',[0.01 0.1],'Value',3);
sliderValue = int32(get(handles.slider1, 'Value'));
switch sliderValue
case 1
cla;
plot(axes,handles.x,handles.y,'r');
case 2
cla;
plot(axes,handles.x,handles.y,'b');
case 3
cla;
plot(axes,handles.x,handles.y,'k');
otherwise
message = sprintf('No case for slider value of %d', sliderValue);
uiwait(warndlg(message));
end
I don't know what I'm doing wrong. I just want to scroll through 3 plots.
Thanks,
Amanda
0 Commenti
Risposta accettata
Image Analyst
il 3 Set 2012
You can't set up the parameters for the slider in it's callback! You just set the value to 3 so matter what your user sets it to, you overwrite it with 3. Put the settings for min, max, and initial value in the Property Inspector in GUIDE, not in the callback.
Secondly, you aren't displaying an image, you're plotting some data in a line plot. and again, you specified that data in the callback so it will be the same every time, regardless of what the user is doing with the slider.
Finally, axes() is a built in function, so you don't want to do this:
axes = handles.axes1;
or else you will be blowing away the built in function. Just pass handles.axes1 directly into plot.
5 Commenti
Image Analyst
il 3 Set 2012
That would work for x and y, though it will just plot a 45 degree line. The handles line is not needed. If you omit the semicolon though, it will print out all values of all the members of handles to the command window.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!