i have made a image browser which displays the file name of the image and i want to use that file name(.jpg) in other pushbutton for embedding kindly help?im new to matlab

2 ビュー (過去 30 日間)
% --- Executes on button press in loadimage.
function loadimage_Callback(hObject, eventdata, handles)
% hObject handle to loadimage (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename]=uigetfile({'*.jpg'},'File Selector');
image=strcat(filename);
axes(handles.axes1);
imshow(image);
set(handles.filename,'string',filename);
function filename_Callback(hObject, eventdata, handles)
% hObject handle to filename (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,'String') returns contents of filename as text
% str2double(get(hObject,'String')) returns contents of filename as a double
% --- Executes during object creation, after setting all properties.
function filename_CreateFcn(hObject, eventdata, handles)
% hObject handle to filename (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in text.
function text_Callback(hObject, eventdata, handles)
% hObject handle to text (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename]=uigetfile({'*.txt'},'FILE Selector');
Path=filename;
text=fileread(Path);
set(handles.edit2,'string',text);
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (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,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in embed.
function embed_Callback(hObject, eventdata, handles)
% hObject handle to embed (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (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,'String') returns contents of edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
  1 件のコメント
Matthew Eicholtz
Matthew Eicholtz 2015 年 6 月 1 日
This question could be made clearer and with less code attached. Are you asking how to display a string on a pushbutton control? Or you want a string to be used as an input in a pushbutton callback? Or something else?

サインインしてコメントする。

回答 (2 件)

Image Analyst
Image Analyst 2015 年 6 月 1 日

Fakhar Alam
Fakhar Alam 2018 年 12 月 28 日
global x;
[a, b]=uigetfile();
x = strcat(b, a);
x = imread(x);
You can use also global variable .
call it against Pushbutton

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by