采样定理matlab gui
时间: 2024-01-12 07:23:07 浏览: 216
以下是一个使用Matlab GUI实现采样定理的完整代码示例:
```matlab
% 创建GUI窗口
fig = uifigure('Name', '采样定理演示');
fig.Position = [100 100 400 300];
% 创建信号输入框
signalInput = uieditfield(fig, 'numeric');
signalInput.Position = [50 200 300 22];
signalInput.Limits = [-10 10];
signalInput.Value = 1;
% 创建采样频率输入框
samplingRateInput = uieditfield(fig, 'numeric');
samplingRateInput.Position = [50 150 300 22];
samplingRateInput.Limits = [1 100];
samplingRateInput.Value = 10;
% 创建绘图按钮
plotButton = uibutton(fig, 'push');
plotButton.Position = [150 100 100 30];
plotButton.Text = '绘图';
plotButton.ButtonPushedFcn = @(btn,event) plotSignal(btn.Parent, signalInput.Value, samplingRateInput.Value);
% 绘图函数
function plotSignal(fig, signal, samplingRate)
% 生成时间序列
t = 0:1/samplingRate:1;
% 生成信号序列
x = signal * sin(2*pi*10*t);
% 绘制信号图像
ax = uiaxes(fig);
ax.Position = [50 50 300 30];
plot(ax, t, x);
xlabel(ax, '时间');
ylabel(ax, '信号');
end
```
这个Matlab GUI程序允许用户输入信号幅度和采样频率,并通过绘图按钮绘制采样后的信号图像。用户可以根据需要调整信号幅度和采样频率来观察采样定理的效果。