How to use a variable from pop up menu callback to another callback functions like slider?

1 次查看(过去 30 天)
I made a popupmenu in GUI with tag Joint_PopUP like following. Whenever I select 'Head' or 'Head_End' from popupmenu, I make changes in 6 arrays of values. I want to use these 6 arrays of values inside another slider callback function in some calculation.
function Joint_PopUp_Callback(hObject, eventdata, handles)
% hObject handle to Joint_PopUp (see GCBO)
handles.Import_CSV;
str = get(hObject, 'String');
val = get(hObject,'Value');
switch str{val};
case'Head'
R_X=handles.Import_CSV(:,1); % I want to use this R_X array in slider callback for some calculation
R_Y=handles.Import_CSV(:,2); % I want to use this R_Y array in slider callback for some calculation
R_Z=handles.Import_CSV(:,3);
T_X= handles.Import_CSV(:,4)/100;
T_Y= handles.Import_CSV(:,5)/100;
T_Z= handles.Import_CSV(:,6)/100;
% handles.RX=R_X
case'Head_End'
R_X=handles.Import_CSV(:,7); % I want to use this R_X array in slider callback for some calculation
R_Y=handles.Import_CSV(:,8); % I want to use this R_Y array in slider callback for some calculation
R_Z=handles.Import_CSV(:,9);
T_X= handles.Import_CSV(:,10)/100;
T_Y= handles.Import_CSV(:,11)/100;
T_Z= handles.Import_CSV(:,12)/100;
end
how do I use those arrays inside another slider callback as shown below?
if true
function StartPointSlider_Callback(hObject, eventdata, handles)
% hObject handle to StartPointSlider (see GCBO)
handles.Import_CSV;
[m,n] =size(handles.Import_CSV(:,1));
set(handles.StartPointSlider,'Max',m);
set(handles.StartPointSlider,'Min',0);
val=get(hObject,'Value');
set(handles.Start_Point_Show,'String',num2str(val));
%R_X %here i need the array from one of the case of popup menu that is already selected
%R_Y %here i need the array from one of the case of popup menu that is already selected
% I do some calculations & plotting ....
guidata(hObject, handles);
end

回答(1 个)

Walter Roberson
Walter Roberson 2018-4-18

类别

Help CenterFile Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by