使用MATLAB无法获得正确的信号正弦波形

时间:2015-04-30 07:16:48

标签: matlab

我想用MATLAB绘制信号的正弦波形。我添加了我的代码。我想为信号x(t),y(t),z(t)和m(t)得到正确的正弦波形。

x(t)的波形看起来有点完美,但对于其他人来说顶端和底端部分不是正弦(如果你在某种程度上放大它们看起来像三角形或尖峰)。

代码部分需要哪些更正?

clc;
clear all;
close all;

figure,
w=0:0.02:pi;
x=10*sin(10*w);
%subplot(2,2,1),
plot(w,x),grid on
title('x(t)');
xlabel('t');
ylabel('x(t)');

figure,
w=0:0.02:pi;
y=20*sin(20*w);
%subplot(2,2,2),
plot(w,y),grid on
title('y(t)');
xlabel('t');
ylabel('y(t)');

figure,
w=0:0.02:pi;
z=30*sin(30*w);
%subplot(2,2,3),
plot(w,z),grid on
title('z(t)');
xlabel('t');
ylabel('z(t)');

figure,
w=0:0.02:pi;
m=10*sin(10*w)+20*sin(20*w)+30*sin(30*w);
plot(w,m),grid on
title('m(t)');
xlabel('t');
ylabel('m(t)');

1 个答案:

答案 0 :(得分:2)

只需增加x轴的步长即可。作为示例,将“w=0:0.02:pi;”替换为“w=0:pi/1024:pi;”(pi / 1024 = 0.0031)。这将为您提供更平滑的输出。