GUI - Trim vector according to slider positions
Ältere Kommentare anzeigen
Hello
I have created a GUI with two sliders and one button. Now I want to use the slider positions to trim a data vector. I tried the following way, but I didn´t work...
My attempt: I changed the slider callback function in a way that a output (hS1) is created. Where hS1 is the slider position.
% --- Executes on slider movement.
function [hS1]=slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
load Data.mat
x=get(hObject,'value');
x_round=round(x)
set(hObject,'value',x_round);
y=(L_KnieAngle3D_orig(x_round,1));
line(x_round,y,'linestyle','none','marker','o','markeredgecolor','r');
hS1=x_round
I did the same with slider Nr. two. As next step I changed the callback function of the pushbutton and added the hS1&hS2 to the input parameters.
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hS1, hS2, hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
load Data.mat
Datavector_new=Datavector_orig(hS1:hS2);
assignin('base','Datavector_new',Datavector_new);
But when I click the pushbutton I only get an empty matrix.
Datavector_new =
Empty matrix: 0-by-1
Does someone have an idea what´s going wrong?
Antworten (1)
Thomas
am 12 Okt. 2012
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!