How to view a more than 1 lines of sentences to uipanel in matlab?

拟墨画扇 提交于 2019-12-11 18:57:53

问题


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.

  1. 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 never set(hp1, [messages]);

  2. uipanel is just a container object, which means that it could contain other GUI objects. You could put a text or edit (See uicontrol) containing your string in the uipanel. But the uipanel itself does not have a 'String' property.

  3. The position vector of uipanel is normalized by default. So all the position values must be between 0 and 1. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!