声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2211|回复: 5

请高人帮忙看个程序,输出变量长度不一样,不会改。。。。

[复制链接]
发表于 2005-11-9 19:26 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
ts=0.1;<BR>fs=1/ts;<BR>df=0.01;<BR>t=[-5:ts:5];<BR>x=zeros(1,length(t));<BR>x(41:51)=t(41:51)+1;<BR>x(52:61)=2;<BR>x(62:81)=-t(62:81)+1;<BR>[X,x,df1]=fftseq(x,ts,df);<BR>X1=X/fs;<BR>f=[0:df:df1*(length(x)-1)]-fs/2;<BR>plot(f,fftshift(abs(X1)));<BR>xlabel('Frequency')<BR>title('Magnitude spectrum of x(t) derived numberically')<BR>目的是画出信号的幅度谱。<BR>信号x(t)的表达式:x(t)=t+1 0&lt;=t&lt;=1<BR>x(t)=2,1&lt;=t&lt;=2<BR>x(t)=-t+1,2&lt;=t&lt;=4<BR>x(t)=0,else<BR>[em04]
回复
分享到:

使用道具 举报

发表于 2005-11-10 01:16 | 显示全部楼层
输出变量长度不一样是什么意思?
发表于 2005-11-10 09:42 | 显示全部楼层
<P>fftseq没有定义啊,能不能把fftseq给出来?</P>
 楼主| 发表于 2005-11-11 22:45 | 显示全部楼层
<P>fftseq在这里,谢谢了,麻烦帮看下</P>
<P>function [M,m,df]=fftseq(m,ts,df) <BR>%       [M,m,df]=fftseq(m,ts,df)<BR>%       [M,m,df]=fftseq(m,ts)<BR>%FFTSEQ     generates M, the FFT of the sequence m.<BR>%       The sequence is zero padded to meet the required frequency resolution df.<BR>%       ts is the sampling interval. The output df is the final frequency resolution.<BR>%       Output m is the zero padded version of input m. M is the FFT.<BR>fs=1/ts;<BR>if nargin == 2<BR>  n1=0;<BR>else<BR>  n1=fs/df;<BR>end<BR>n2=length(m);<BR>n=2^(max(nextpow2(n1),nextpow2(n2)));<BR>M=fft(m,n);<BR>m=[m,zeros(1,n-n2)];<BR>df=fs/n;<BR></P>
发表于 2005-11-12 12:13 | 显示全部楼层
<P>这个是由于df1和df不一致造成的,把f=[0:df:df1*(length(x)-1)]-fs/2里的df1改成df或者把df改成df1就行了</P>
<P>不知道你这个程序是什么意思,不知道用那种改法</P>
[此贴子已经被作者于2005-11-12 12:14:31编辑过]

 楼主| 发表于 2005-11-13 11:43 | 显示全部楼层
非常感谢,按照你说的可以运行了,多谢!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-6 00:25 , Processed in 0.086311 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表