How could I passing parameters from .m file to GUI

6 ビュー (過去 30 日間)
LainHE
LainHE 2019 年 3 月 15 日
回答済み: Rik 2019 年 3 月 24 日
I have a .m file that would get 11 different results in text. And I want to show those results in the GUI. I tried to pass the parameters into static text. but it seems not working. Could anyone help me?
This is my .m file's function
function [title1,title2,title3,title4,title5,title6,title7,title8,title9,title10,title11] = noOriginalImage
I tried to do such things like that, but it obvious not working.
function pushbutton4_Callback(title1,title2,title3,title4,title5,title6,title7,title8,title9,title10,title11,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)
[title1,title2,title3,title4,title5,title6,title7,title8,title9,title10,title11] = noOriginallmage;
set(handles.text10,'string',title1,title2,title3,title4,title5,title6,title7,title8,title9,title10,title11);
Sorry about bad coding, I am a novice.
I have been tried to search relevant questions or video courses, but I could not find it or understand.

回答 (2 件)

amin ya
amin ya 2019 年 3 月 15 日
I don't understand your problem
If you are trying to print something use one of the following commands
fprintf()
disp()
If you are trying to make a GUI use this tutorial:
  1 件のコメント
LainHE
LainHE 2019 年 3 月 16 日
編集済み: LainHE 2019 年 3 月 16 日
What I thinking is passing the parameters from a .m file to the push button 4 of GUI.
(The .m file is called noOriginalImage.m, which is not .m file of GUI. They are different files in other words. )
Then, I am going to make the content shows in text10. (I think use set() could reach it? I am not sure because I did not pass the parameters successfully.)
The video seems just talking about passing the parameters within GUI. That is not what I need.
Sorry about my poor English. It is not my native language.

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


Rik
Rik 2019 年 3 月 24 日
You shouldn't change the function headers that GUIDE generates. The fact that your function is not in the same file doesn't matter as long as it is on your search path. Something like the function below should help you out.
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)
%load variables from external function
[title1,title2,title3,title4,title5,title6,title7,title8,title9,title10,title11] = noOriginallmage;
%set the text10 field to the content of these variables
set(handles.text10,'string',{title1,title2,title3,title4,title5,title6,title7,title8,title9,title10,title11});
Or a lot easier to read:
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)
%load variables from external function
titles=cell(1,11);
[titles{:}] = noOriginallmage;
%set the text10 field to the content of these variables
set(handles.text10,'string',titles);

カテゴリ

Help Center および File ExchangeLanguage Support についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by