简体   繁体   English

我如何在Matlab中生成正弦波?

[英]How can i generate sinusoidal wave in Matlab?

How can i generate sinusoidal wave in Matlab with frequency of 1 HZ and sampling frequency 200 HZ and sequence length N=1024 ? 如何在Matlab中生成频率为1 HZ,采样频率为200 HZ,序列长度N = 1024的正弦波?

N=1024;
fs=200;
f=1;
ts=1/fs;
t=-10:ts:10;
i=1:2:N;
x=sin(2*pi*f*i*t);

Is this correct ? 这个对吗 ?

The code below will create a 1024 sample sine wave that has a frequency of 1Hz and sampling rate of 200 Hz. 下面的代码将创建一个1024采样正弦波,其频率为1Hz,采样率为200 Hz。

N=1024;
fs=200;
f=1;
ts=1/fs;
t = ts*(0:N-1);
x=sin(2*pi*f*t);
plot(t,x)

This should plot what you want 这应该画出你想要的

fs=200;
f=1;
N=1024;
ts=1/fs;
t = ts*(0:N-1);
x=sin(2*pi*f*t);
f1 = 1 ;
N = 1024 ;
fs = 200 ;
ts = 1/fs ;
t = -(N/(2*fs)):ts:(N/(2*fs) ;
y = sin(2*pi*f1*t) ;
plot(t,y)

You do not need to use i for getting 1024 samples out. 您无需使用i即可获取1024个样本。 this can be done by choosing correct start and stop values for t. 这可以通过为t选择正确的起始值和终止值来完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM