How can I use variable(matrix) from one callback function to other call back function for computation?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
%First function
% --- Executes on button press in load_life. function load_life_Callback(hObject, eventdata, handles) % hObject handle to load_life (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
%Call Std file browser [filename, pathname] = uigetfile({'*.xlsx','Excel Files (.xlsx)'; ... '.*', 'All Files (.)'}, ... 'Select a Life data file'); % Handle no specified path if isequal(filename,0) | isequal(pathname,0) disp('File selection cancelled') else disp(['User selected ', fullfile(pathname, filename)]) filename = fullfile(pathname, filename); % build full filename from uigetfile dlg cd(pathname);
% assign variable to workspace
% evalin('base', 'clear all');
l_matrix = xlsread(filename,'B15:U44');
assignin('base','l_matrix',l_matrix);
l_vg_percent = xlsread(filename,'B11:U11');
assignin('base','l_vg_percent',l_vg_percent);
l_exp_ratio = xlsread(filename,'A15:A44');
assignin('base','l_exp_ratio',l_exp_ratio);
% %%Assign variables to handles structure
handles.data.l_matrix = l_matrix;
handles.l_vg_percent = l_vg_percent;
handles.data.l_exp_ratio = l_exp_ratio;
end
guidata(hObject, handles);
% Second function:
% --- Executes on button press in force_push. function force_push_Callback(hObject, eventdata, handles) % hObject handle to force_push (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
%Call Std file browser [filename, pathname] = uigetfile({'*.xlsx','Excel Files (.xlsx)'; ... '.*', 'All Files (.)'}, ... 'Select a Life data file'); % Handle no specified path if isequal(filename,0) | isequal(pathname,0) disp('File selection cancelled') else disp(['User selected ', fullfile(pathname, filename)]) filename = fullfile(pathname, filename); % build full filename from uigetfile dlg cd(pathname);
% assign variable to workspace
f_matrix = xlsread(filename,'B6:K9')
assignin('base','f_matrix',f_matrix);
f_vg_percent = xlsread(filename,'B3:K3')
assignin('base','f_vg_percent',f_vg_percent);
f_exp_ratio = xlsread(filename,'A6:A9')
assignin('base','f_exp_ratio',f_exp_ratio);
%%%Assign variables to handles structure
handles.data.f_matrix = f_matrix;
handles.data.f_vg_percent = f_vg_percent;
handles.data.f_exp_ratio = f_exp_ratio;
% Force to torque multiplier value
multiplier_val=[0.01 0.02 0.02 0.012 0.01 0.01 0.01 0.01 0.0091 0.007;...
0.01 0.02 0.012 0.012 0.01 0.011 0.01 0.01 0.09 0.007;...
0.01 0.02 0.02 0.02 0.011 0.01 0.01 0.01 0.009 0.007;...
0.01 0.02 0.012 0.012 0.011 0.011 0.01 0.01 0.09 0.007]
assignin('base','multiplier_val',multiplier_val);
handles.data.multiplier_val = multiplier_val;
t_matrix = f_matrix.*multiplier_val
assignin('base','t_matrix',t_matrix);
end
guidata(hObject, handles);
% Third function (this I need to perform)

% --- Executes on button press in t_interp_push. function t_interp_push_Callback(hObject, eventdata, handles) % hObject handle to t_interp_push (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
[X1, Y1]= meshgrid(l_vg_percent,l_exp_ratio); interp_torque = interp2(f_vg_percent,f_exp_ratio,t_matrix,X1,Y1,'linear');
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!