Now I tried a second attempt.
I assigned the slider position to variables (x1,x2) in the workspace. Then I added the input variables x1,x2 and Datavector to the pushbutton1_Callback-function.
% --- Executes on slider movement.
function 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));
set(line,'xdata',x_round,'ydata',y);
line(x_round,y,'linestyle','none','marker','o','markeredgecolor','r');
x1=x_round
assignin('base','x1',x1);
The pushbutton-function should create an new vector, called Datavector_new, with the limits x1 and x2.
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(x1, x2, Datavector, 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)
Datavector_new=Datavector(x1:x2)
assignin('base','Datavector_new',Datavector_new);
But now I get the message:
Datavector_new =
1x0 struct array with fields:
figure1
pushbutton1
text3
text1
slider2
slider1
axes1
output
Does someone have an idea what went wrong? Normally the "Datavector" should be shortened by the limits x1 and x2.