Digital Signal Processing Reference
In-Depth Information
%This program needs p2f1.m, pulse.m and forier.m
% demo package written by Dr K.V.Rangarao
% this computes theoritical
% Fourier Series Coefficients of a rectangular
% pulse and compares with the FFT generated
% Fourier Series Coefficients.
clear;clf
tow=0.1; T=1.2; f1=1/T; A=1.3;mm=9
N=2^mm; x=pulse(tow,T,N); x=x*A;delt=1e-3;
n1=round(N/2);
[f,a,b]=forier(x,delt);
[a1,b1,F]=p2f 1(tow,f 1,A,N);
%subplot (211) ;plot(x) ;grid;
[aa ii]=max(a); s=ii-20;e=ii+20;
subplot(221);plot(f(s:e),a(s:e),'o',f(s:e),a1(s:e),'.-');
grid;title('A')
ylabel('ak');xlabel('Co-sine');
subplot(222);plot(f(s:e),b(s:e),'o',f(s:e),b1(s:e),'.-');
grid;title('B')
ylabel('bk');xlabel('sine');
%print -depsc f4_4
A.4.2 Program f 4_56
%Digital Signal Processing:A Practitioner's Approach
%Dr.Kaluri Venkata Ranga Rao, kaluri@ieee.org
%Generates figure 4.11,4,12
clear;close;
nx=50;ny=15;
kx=1:nx; ky=1:ny; f=0.05;
x=sin(2*pi*f*kx);
y=cos(2*pi*f*ky);
z=conv(x,y);t=1:length(z);
%subplot (211);
%plot (t,z); grid
m=nx-ny;
pad=ones([1 m])*0;
y(ny+1:nx)=pad;
zhat=real(ifft(fft(x).*fft(y)));
t1=1:length(zhat);
subplot(221)
plot(t,z,'.-',t1,zhat,'o');grid;nn=length(zhat);
e=z; e(1: nn)=e(1:nn)-zhat;
Search WWH ::




Custom Search