Info

此问题已关闭。 请重新打开它进行编辑或回答。

sir i have made a gui in which a push button gets images from folders of the computeers and i have a edit texts which shows the name of the image and i want to use that image for anothers pushbutton can you suggest me a way?

1 次查看(过去 30 天)
[filename]=uigetfile({'*.jpg'},'File Selector');
image=strcat(filename);
axes(handles.axes1);
imshow(image);
set(handles.filename,'string',filename);
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
  1 个评论
Jan
Jan 2015-6-1
编辑:Jan 2015-6-1
I've edited your code to improve the readability. Please use the "{} Code" button.
The question is not clear. "Use that image for another pushbutton"?
strcat(filename) does nothing - I assume you need the filepath in addition? See: help uigetfile.

回答(1 个)

Image Analyst
Image Analyst 2015-6-1
Requiring users to type in the name of the file they want is not user friendly. Why don't you just load up a listbox of all the files that they might choose. See MAGIC: http://www.mathworks.com/matlabcentral/fileexchange/24224-magic-matlab-generic-imaging-component
Also read the FAQ to see how you can transfer variables between callback functions: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by