问题
I wanna view the result of the "Detection" function. In the "Detection" function there is "messeges" variable. From the function, i want that all the sentences in messeges variable can be preview in my GUI esspecially in UIPANEL.
How to do it. I have made a Panel design in matlab with tag=uipanel1.
[messeges]=Detection(handles.citra1); %it's to call the Detection
function.
here is my UIPANEL CODE..
hp1=uipanel('Position', [100 100 700 500],...
'Title','UI Panel 1');
set(hp1, [messeges]);
but it cannot display the sentences from the messeges variable into the panel1 that i had made before..
There are errors messeges like this
??? Error using ==> set
There is no 'jumlah pasang pixel yang pada objek 13
adalah 1000' property in the 'uipanel' class.
Error in ==> deteksi2citra>pushbutton3_Callback at 124
set(hp1, [messeges]);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> deteksi2citra at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)deteksi2citra('pushbutton3_Callback',
hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
I have find the rellated topic but i cannot find the solution.
Please help me..
回答1:
There are three major problems with your code.
You always have to set a property of an object to something in Matlab.
set(Object_Handle,'PropertyName1',PropertyValue1,... 'PropertyName2',PropertyValue2...)
Thus you might be able to write this
set(hp1, 'String', messages);
but neverset(hp1, [messages]);
uipanel is just a container object, which means that it could contain other GUI objects. You could put a
text
oredit
(See uicontrol) containing your string in the uipanel. But the uipanel itself does not have a'String'
property.The
position
vector of uipanel isnormalized
by default. So all the position values must be between0
and1
. See position vector here for more info.
Example of putting multi-line text
in uipanel
:
(Note that this code is a standalone or self consistent code (unlike GUIDE), thus you can just copy and paste this code and run it in matlab command window.)
str = sprintf('Your \n Multiline \n String ...');
hp1 = uipanel('Title','UI Panel 1',...
'Position', [.25 .1 .67 .67]);
uicontrol(...
'Parent', hp1,...
'Style','text',...
'Units', 'Normalized', 'Position', [0 0 1 1],...
'String', str);
来源:https://stackoverflow.com/questions/17651532/how-to-view-a-more-than-1-lines-of-sentences-to-uipanel-in-matlab