在Matlab中生成简单的正弦波 [英] generate simple sine wave in matlab
问题描述
如何在matlab中生成简单的正弦波?
How do I generate a simple sine wave in matlab?
我想在24小时内生成一个代表15度幅度的温度信号的波,我该怎么做?
I would like to generate a wave which represents a temperature signal with an amplitude of 15 degrees during a 24 hour period, how can I do this?
t = 1:24
x = 15.*sin(pi*t)
plot(t,x)
其中15是振幅.这不会产生我所期望的正弦波.我原本希望看到一个波在24小时内以15的幅度延伸,例如最小值为5,最大值为20(如何在方程式中包括这些?).
where 15 is the amplitude. This does not generate a sine wave as I expected. I was expecting to see one wave which extends over a 24 hour period with an amplitude of 15, say with the lowest value of 5 and a maximum of 20 (how do I include these in the equation?).
推荐答案
添加常量并调整频率:
x = 5 + 15*sin(2*pi*t/24);
在您的代码中,频率不正确,并且采样周期对于该频率而言太大:您有混叠.这就是为什么看不到正弦波的原因.
In your code the frequency is incorrect, and the sampling period is too large for that frequency: you have aliasing. That's why you don't see a sine wave.
这篇关于在Matlab中生成简单的正弦波的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!