GUI sliders that update a plot and create a subsection of data

2 visualizaciones (últimos 30 días)
Bran
Bran el 16 de Mzo. de 2015
Comentada: Bran el 16 de Mzo. de 2015
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.

Respuestas (1)

Jan
Jan el 16 de Mzo. de 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.
  2 comentarios
Bran
Bran el 16 de Mzo. de 2015
Apologies, I wasnt very clear. If they define the subset by placing the sliders half way along the plot then I would like for the new Dataset to be (500:n) if for example they chose to place the slider at 500 and the other slider at the end of the dataset (n). Just to be clear in the code above n is the length of my initial Dataset
Bran
Bran el 16 de Mzo. de 2015
Also just a side not has the plotxlim changed also as I have the follwing error after rectifying the one above;
Undefined function 'plotxlim' for input arguments of type 'matlab.ui.control.UIControl'.
Error while evaluating UIControl Callback

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by