當前位置:編程學習大全網 - 編程語言 - MATLAB圖形用戶界面設計問題?

MATLAB圖形用戶界面設計問題?

將這些復制到matlab,新建腳本運行就可以了

function [] = GUI1()

S.fh = figure('units', 'pixels', ...

'position', [100 100 800 600], ...

'menubar', 'none', ...

'name', 'GUI_13', ...

'numbertitle', 'off', ...

'resize', 'off');

% 滑動條

S.sl = uicontrol('style', 'slide', ...

'unit', 'pix', ...

'position', [20 10 260 30], ...

'min', 1, 'max', 100, 'val', 50); % min max 為滾動條頻率的範圍

% 顯示框

S.ed = uicontrol('style', 'edit', ...

'unit', 'pix', ...

'position', [20 50 260 30], ...

'fontsize', 16, ...

'string', '50');

S.ax = axes('units', 'pixels', ...

'position', [50 150 600 400]);

set([S.ed, S.sl], 'call', {@ed_call, S}); % Shared Callback.

function [] = ed_call(varargin)

% Callback for the edit box and slider.

[h, S] = varargin{[1, 3]}; % Get calling handle and structure.

switch h% Who called?

case S.ed

L = get(S.sl, {'min', 'max', 'value'}); % Get the slider's info.

E = str2double(get(h, 'string')); % Numerical edit string.

if E >= L{1} && E <= L{2}

set(S.sl, 'value', E)% E falls within range of slider.

else

set(h, 'string', L{3})% User tried to set slider out of range.

end

% 獲取當前頻率

f0 = get(S.sl, 'value');

% 開始繪圖

t = linspace(0,2, 1000);

plot(S.ax, t, cos(2*pi*f0*t), '-r')

case S.sl

set(S.ed, 'string', get(h, 'value'))% Set edit to current slider.

% 獲取當前頻率

f0 = get(S.sl, 'value');

% 開始繪圖

t = linspace(0,2, 1000);

plot(S.ax, t, cos(2*pi*f0*t), '-r')

otherwise

% Do nothing, or whatever.

end

  • 上一篇:vb 十進制轉換成 八進制 二進制原碼 二進制補碼 二進制反碼 程序
  • 下一篇:畫家波提切利的藝術風格是什麽
  • copyright 2024編程學習大全網