How to pass message box value to the text box?

1 次查看(过去 30 天)
In my matlab application it run a .m file using matlab gui. that application gives the ouput in messagebox as "belongs to class 1,..". I want to pass this value to a text box in matlab gui. Please can you explain how can I do it?

采纳的回答

Adam Danz
Adam Danz 2018-12-12
If I understand you correctly, you want to extract the text from a message box and copy it to a text box in your GUI.
Step 1: Copy the message box string.
mh = msgbox('Copy this text.'); %Create a message box
th = findall(mh, 'Type', 'Text'); %Get the handle to the text within the box
msgString = th.String{:}; %Copy the string
Step 2: put the string in your your text box
The handle to you text box in this example is h.text1.
h.text1.String = msgString;
  2 个评论
Sam Upeshala
Sam Upeshala 2018-12-12
编辑:Sam Upeshala 2018-12-12
thank you sir..
I get the out put from this code.
im=imread(fname);
imshow(im);
title('Test Image');
%% Fond out which Class it Belongs to
Ftest=FeatureStatistical(im);
%% Compare with Database
load db.mat
Ftrain=db(:,[1,2]);
ctrain=db(:,3);
for(i=1:size(Ftrain,1))
dist(i,:)=sum(abs(Ftrain(i,:)-Ftest));
end
Min=min(dist);
if(Min<3)
m=find(dist==Min,1);
det_class=ctrain(m);
msgbox(strcat('detected class',num2str(det_class)));
else
msgbox('Not Exist');
end
can I extract that value to a text box?
Adam Danz
Adam Danz 2018-12-12
To use my method, you need the handles to your message box.
mh = msgbox(strcat('detected class',num2str(det_class)));
mh = msgbox('Not Exist');
Then follow my example.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by