|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
实现通信里抽样定理的matlab程序
1)
function [M,m,df]=fftseq(m,ts,df)
[M,m,df]=fftseq(m,ts,df) ;
[M,m,df]=fftseq(m,ts) ;
fs=1/ts;
if nargin == 2
n1=0;
else
n1=fs/df;
end
n2=length(m);
n=2^(max(nextpow2(n1),nextpow2(n2)));
M=fft(m,n);
m=[m,zeros(1,n-n2)];
df=fs/n;
2)clear
t0=10;
ts=0.001;
ts1=0.1;
ts2=0.05;
fs=1/ts;
fs1=1/ts1;
fs2=1/ts2;
df=0.5;
t=[-t0/2:ts:t0/2];
x=sin(20*t);
m=x./t;
w=t0/(2*ts)+1;
m(w)=20;
m=m.*cos(100*t);
[M,mn,dfy]=fftseq(m,ts,df);
M=M/fs;
f=[0:dfy:dfy*length(mn)-dfy]-fs/2;
pause;
subplot(2,1,1);
plot(f,abs(fftshift(M)));
axis([-50,50,0.3]);
t1=[-t0/2:ts1:t0/2];
x1=sin(20*t1);
m1==x1./t1;
w1=t0/(2*ts1)+1;
m1(w1)=20;
m1=m1.*cos(100*t1);
[M1,mn1,df1]=fftseq(m1,ts1,df);
M1=M1/fs1;
N1=[M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1,M1];
f1=[-7*df1*length(mn1):df1:6*df1*length(mn1)-df1]-fs1/2;
subplot(2,2,3);
plot(f1,abs(fftshift(N1)));
title('不满足采样要求');
t2=[-t0/2:ts2:t0/2];
x2=sin(20*t2);
m2=x2./t2;
w2=t0/(2*ts2)+1;
m2(w2)=20;
m2=m2.*cos(100*t2);
[M2,mn2,df2]=fftseq(m2,ts2,df);
M2=M2/fs2;
N2=[M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2,M2];
f2=[-7*df2*length(mn2):df2:6*df2*length(mn2)-df2]-fs2/2;
subplot(2,2,4);
title('满足采样要求');
xlable('频率')
出现错误:??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.
Error in ==> e:\MATLAB6p5\work\fftseq.m
On line 2 ==> [M,mn,df]=fftseq(m,ts,df) ;
Error in ==> e:\MATLAB6p5\work\bandpsample.m
On line 16 ==> [M,mn,dfy]=fftseq(m,ts,df); |
|