xueke8668 发表于 2006-5-17 08:33

[求助]fft的matlab程序

求快速傅里叶变换的matlab程序

wgun 发表于 2006-5-17 09:57

y=fft(x)

sunny567 发表于 2006-5-17 20:10

这个是最简单的,你看看有没有用。<BR>
<P 0cm 0cm 0pt"><FONT face="Times New Roman">N=16,</FONT>分析<FONT face="Times New Roman">16</FONT>点频谱:</P>
<P 0cm 0cm 0pt"><B>程序:</B></P>
<P 0cm 0cm 0pt"><FONT face="Times New Roman">fs=5</FONT></P>
<P 0cm 0cm 0pt"><FONT face="Times New Roman">N=16;</FONT></P>
<P 0cm 0cm 0pt"><FONT face="Times New Roman">t=1/fs;</FONT></P>
<P 0cm 0cm 0pt"><FONT face="Times New Roman">f1=0.24;f2=0.26;</FONT></P>
<P 0cm 0cm 0pt"><FONT face="Times New Roman">n=0:N-1;</FONT></P>
<P 0cm 0cm 0pt"><FONT face="Times New Roman">x=cos(2*pi*t*f1*n)+cos(2*pi*t*f2*n);</FONT></P>
<P 0cm 0cm 0pt"><FONT face="Times New Roman">figure,stem(x);</FONT></P>
<P 0cm 0cm 0pt"><FONT face="Times New Roman">y=t*abs(fft(x,N));</FONT></P>
<P 0cm 0cm 0pt"><FONT face="Times New Roman">figure;</FONT></P>
<P 0cm 0cm 0pt"><FONT face="Times New Roman">plot(y,'*')<BR></P>
<P 0cm 0cm 0pt">N=16,分析64点频谱:</P>
<P 0cm 0cm 0pt"><B>程序:<p></p></B></P>
<P 0cm 0cm 0pt">fs=5;</P>
<P 0cm 0cm 0pt">N=64;</P>
<P 0cm 0cm 0pt">t=1/fs;</P>
<P 0cm 0cm 0pt">f1=0.24;f2=0.26;</P>
<P 0cm 0cm 0pt">n=0:15;</P>
<P 0cm 0cm 0pt">x=cos(2*pi*t*f1*n)+cos(2*pi*t*f2*n);</P>
<P 0cm 0cm 0pt">figure,stem(x);</P>
<P 0cm 0cm 0pt">y=t*abs(fft(x,64));</P>
<P 0cm 0cm 0pt">figure;</P>
<P 0cm 0cm 0pt">plot(y,'*');</P>
<P 0cm 0cm 0pt">N=64,分析64点频谱:</P>
<P 0cm 0cm 0pt"><B>程序:<p></p></B></P>
<P 0cm 0cm 0pt">fs=5;</P>
<P 0cm 0cm 0pt">N=64;</P>
<P 0cm 0cm 0pt">t=1/fs;</P>
<P 0cm 0cm 0pt">f1=0.24;f2=0.26;</P>
<P 0cm 0cm 0pt">n=0:N-1;</P>
<P 0cm 0cm 0pt">x=cos(2*pi*t*f1*n)+cos(2*pi*t*f2*n);</P>
<P 0cm 0cm 0pt">figure,stem(x);</P>
<P 0cm 0cm 0pt">y=t*abs(fft(x,N));</P>
<P 0cm 0cm 0pt">figure;</P>
<P 0cm 0cm 0pt">plot(y,'*')</P>
<P 0cm 0cm 0pt"></FONT></P>

kingfly 发表于 2006-5-17 22:50

N=10000;%数据个数<BR>Freq=1000;%采样频率Hz<BR>Y=fft(data(1:N)); %取数据前N个<BR>Pyy=Y.*conj(Y)/N;<BR>f=Freq*(0:fix(0.25*N))/N;<BR>plot(f,Pyy(1:(fix(0.25*N)+1)))<BR>title('Frequency content')<BR>xlabel('frequency (Hz)')

qiuqia17 发表于 2006-5-18 12:24

回复:(xueke8668)[求助]fft的matlab程序

<P>把问题 描述清楚 ~~~<BR><BR><BR>   你要 什么样的谱负半轴上的要不要</P>

蓝色泪花雨 发表于 2006-5-19 12:10

呵呵,还是比较好的

yuliang 发表于 2006-6-3 18:22

请教各位,我现在有一组波形的采样数据x(n),在做完Y=fft(X)之后想画出波形的频域图像,请问还需要加上一些什么语句么?特别是X轴要求是频率,应该怎样做呢?谢谢
页: [1]
查看完整版本: [求助]fft的matlab程序