Displaying analytical results in the MATLAB GUI

My problem is this: I have a MATLAB GUI, and I want to get analytic results if I run it to display in my GUI, and not in the command window. I tried using the list to display the results due to the sliders that are automatically created for the list, but this did not work. How can I display data, possibly using a static text field?

+3
source share
4 answers

First, you will need to make sure that you suppress any output in the command window. You can do this by making sure that you end the lines with a semicolon , avoid using DISP to display data, and do not use the FPRINTF function to send data to standard output (i.e. the command window).

-, , "" . , UITABLE ( Azim , MATLAB). , , . :

hList = uicontrol('Style','text','Position',[100 100 200 200]);
set(hList,'String',{'Line 1'; 'Line 2'});  % Displays 2 lines, one string each
vec = rand(3,1);  % Column array of 3 random values
set(hList,'String',num2str(vec));  % Displays 3 lines, one number per line

, , .

.. , , , . . , "FontSize" , ( ) , , .


EDIT: ...

, - , , , , . , , ( ) , .

-, m :

callback_scrolltext.m

function callback_scrolltext(source,event,hText)
  textString = get(hText,'UserData');
  nLines = numel(textString);
  lineIndex = nLines-round(get(source,'Value'));
  set(hText,'String',textString(lineIndex:nLines));
end

update_scrolltext.m

function update_scrolltext(newText,hText,hSlider)
  newText = textwrap(hText,newText);
  set(hText,'String',newText,'UserData',newText);
  nRows = numel(newText);
  if (nRows < 2),
    sliderEnable = 'off';
  else
    sliderEnable = 'on';
  end
  nRows = max(nRows-1,1);
  set(hSlider,'Enable',sliderEnable,'Max',nRows,...
      'SliderStep',[1 3]./nRows,'Value',nRows);
end

-, GUI . "" , , hParent:

hParent = figure;
hText = uicontrol('Style','text',...
                  'Parent',hParent,...
                  'Units','pixels',...
                  'Position',[100 100 100 40]);
hSlider = uicontrol('Style','slider',...
                    'Parent',hParent,...
                    'Units','pixels',...
                    'Position',[200 100 10 40],...
                    'Enable','off',...
                    'Callback',{@callback_scrolltext,hText});

, , , update_scrolltext , ( , TEXTWRAP is) . :

update_scrolltext({'hello'},hText,hSlider);
update_scrolltext({'hello'; 'there'; 'silly'; 'world'},hText,hSlider);

! =)

+8

listbox . , .

- uicontrol listbox;

message = 'New output to be appended';
set(status,'String', [message; get(status,'String')]);

, , uicontrol , . , uicontrol "" :

set(status,'String', [message; {get(status,'String')}]);
+2

,

figure(gcf)
text(offsetX1, offsetX1, ['result 1: ' num2str(result1)])
text(offsetX2, offsetX2, ['result 2: ' num2str(result2)])

, , , .

+1

Matlab Gui, , - , text-edit ? , . , . , .

0

Source: https://habr.com/ru/post/1709972/


All Articles