我怎样才能传出倒计时的重大信息? MATLAB

时间:2015-11-17 18:03:40

标签: matlab matlab-figure matlab-guide

我想制作倒计时的大消息。我找到了一个带有消息对话框的表单,但它比我想要的小。 这是我已经证明的代码,但它非常小,我需要倒计时的重要信息。

msgbox('3');
pause(1)
msgbox('2');
pause(1)
msgbox('1');
pause(1)
msbox('smile');

我该怎么做?

2 个答案:

答案 0 :(得分:3)

您的示例中有很多冗余代码。这有点清洁:

% Initialize our figure
fh = figure( ...
    'MenuBar', 'none', ...     % Get rid of unnecessary UI elements
    'DockControls', 'off', ... % Get rid of unnecessary UI elements
    'ToolBar', 'none', ...     % Get rid of unnecessary UI elements
    'Units', 'Pixels', ...     % Makes it a bit easier to set position
    'Position', [500 300 500 500] ... % Position, pixels [x, y, width, height]
    );

% Initialize our text box
textbox = uicontrol( ...
    'Parent', fh, ...              % Put it in our figure window
    'Style', 'text', ...           % We want a text box
    'Units', 'Normalized', ...     % Scale the box relative to figure window
    'Position', [0, 0, 1, 1], ...  % Scale the box relative to figure window
    'FontUnits', 'Normalized', ... % Scale font relative to text box
    'FontSize', 0.8 ...            % Scale font relative to text box
    );

startnum = 10; % Our starting number
while startnum >= 0
    set(textbox, 'String', startnum); % Update text box string
    pause(1)                          % Wait 1 second
    startnum = startnum - 1;          % Subtract one from our counter
end

答案 1 :(得分:0)

最后我找到了解决方案。

{{1}}