我需要创建一个振幅为5 cm,频率为0.8 Hz的正弦信号。
请帮助
我的代码:
A=5;fs=0.8;
te=1/fs;
t=0:te:0.8;
s=A*sin(2*pi*fs*t);
plot(s,t)
当我绘图时,什么也没出现
答案 0 :(得分:0)
我可以向您建议以下解决方案:
f = 0.8;
t = linspace(0,f,1000);
a = 4;
y = a*sin(2*pi*f*t);
plot(t,y)
或
function [ ] = singen(f, amp)
clf;
t = linspace(0,1/f,1000);
x=amp*sin(2*pi*f*t);
plot(t, x);
xlabel('Time (seconds)');
ylabel('Amplitude');
h = strcat({'Sinusoid of '}, num2str(freq), {'Hz with fs = '}, num2str(fs), {' Hz'});
title(h), grid on;
end