GUI sliders that update a plot and create a subsection of data
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to create a GUI with uicontrol with sliders that will go on to section up my dataset depending on where the user sets the sliders on the data, How can I do this and use the values set by the user to trim down my dataset and use the smaller dataset for the rest of my function? This is what I have created so far
sldplot=plot(data)
btn = uicontrol('Style', 'pushbutton', 'String', 'Clear','Position', [20 20 50 20],'Callback', 'cla');
sld = uicontrol('Style', 'slider','Min',1,'Max',n,'Value',41,'Position', [400 20 120 20],'Callback', @plotxlim);
sld2 = uicontrol('Style', 'slider','Min',1,'Max',n,'Value',41,'Position', [200 20 120 20],'Callback', @plotxlim);
txt = uicontrol('Style','text','Position',[400 45 120 20],'String','First cut');
txt2 = uicontrol('Style','text','Position',[450 50 125 25],'String','Second cut');
addlistener(sld,'ActionEvent',@(sldObject, event) makeplot(sldObject, event,xn,sldplot));
addlistener(sld2,'ActionEvent',@(sld2Object, event) makeplot(sld2Object, event,xn,sldplot));
n2 = get(sldObject,'Value');
n3 = get(sld2Object, 'Value');
set(sldplot,'ydata',x.^n);
drawnow;
but there is some issues I keep getting an error saying that 'ActionEvent' is not defined for class 'matlab.ui.control.UIControl'. Also I am not sure how to use this to then create a new subset of data.
0 Kommentare
Antworten (1)
Jan
am 16 Mär. 2015
Since Matlab 2014a the event has a new name:
addlistener(hSlider, 'ContinuousValueChange', @myCallbackFcn);
It is not clear how you define "a new subset of data". Therefore I cannot answer the 2nd question.
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps 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!