1
我想在matlab GUI中的另一個函數中訪問一個函數中變量的值。 例如訪問Matlab中另一個函數中一個函數的變量
% --- Executes on button press in browseCoverHide.
function browseCoverHide_Callback(hObject, eventdata, handles)
% hObject handle to browseCoverHide (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[File,Path] = uigetfile('*.png','Select Image');
path = strcat(Path,File);
global covImg
covImg = imread(path);
axes(handles.axes1);
imshow(covImg);
% --- Executes on button press in browseSecImg.
function browseSecImg_Callback(hObject, eventdata, handles)
% hObject handle to browseSecImg (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global covImg
axes(handles.axes3);
imshow(covImg);
在這裏,我想訪問CovImg
在function browseSecImg_Callback
從function browseCoverHide_Callback
,但它無法正常工作。
相似問題:http://stackoverflow.com/q/10772099/97160 – Amro