You are on page 1of 6

305122033 '

203434112
MATLAB 2
function[] = present_signal(x1,title1,x2,title2 )
X1=abs(fft(x1,1024));
s1=floor((length(x1)-1)/2);
n1=-s1:1:-s1+length(x1)-1;
w=linspace(-2*pi,2*pi,2048);
if nargin<3
subplot(2,1,1)
stem(n1,x1);
grid;
title(title1);
xlabel('n');
ylabel('x1[n]');
subplot(2,1,2)
plot(w,repmat(X1,1,2));
xlabel('w[rad/sec]');
ylabel('X1(exp(jw)');
else
X2=abs(fft(x2,1024));
s2=floor((length(x2)-1)/2);
n2=-s1:1:-s1+length(x2)-1;
subplot(2,2,1)
stem(n1,x1);
grid;
title(title1);
xlabel('n');
ylabel('x1[n]');
subplot(2,2,3)
plot(w,repmat(X1,1,2));
xlabel('w[rad/sec]');
ylabel('X1(exp(jw)');
grid;
subplot(2,2,2)
stem(n2,x2);
title(title2);
xlabel('n');
ylabel('x2[n]');
grid;
subplot(2,2,4)
plot(w,repmat(X2,1,2));
xlabel('w[rad/sec]');
ylabel('X2(exp(jw)');
grid;

: 1
nargin
.
stem 5
.plot
fft

N .
.1024 N , [0,2]
,[-2,2]
.repmat

end

5 2
wm = 0.8257 [rad] -
. , wm < /M - M
.

3 .3

M=3 >- ,wm = 0.8257 < /M = 1.0472 - .


rescaling
.3

.5
.aliasing
aliasing .anti aliasing

M=5 ,wm = 0.8257 > /M = 0.628 - (aliasing


,w = - ).

( w =
0)

3 5 3 ,5
, .
,
L L-1 .

L .L

. resample 2/3 -

n=-25:25;
x=(pi*sinc(pi*n/8)/4).^2;
present_signal(x,'x[n]')
x1=downsample(x,3);
x2=decimate(x,3);
present_signal(x1,'downsample3',x2,'decimate-3')
x1=downsample(x,5);
x2=decimate(x,5);
present_signal(x1,'downsample5',x2,'decimate-5')
x1=upsample(x,3);
x2=interp(x,3);
present_signal(x1,'upsample-3',x2,'interp-3')
x1=upsample(x,5);
x2=interp(x,5);
present_signal(x1,'upsample-5',x2,'interp-5')
x1=resample(x,2,3);
present_signal(x,'resample 2/3')
diary off
5

:3

N=1024;
w=linspace(-2*pi,2*pi,2*N);
x=wavread('sin.wav'); //importing the file
x=x';
x_down=downsample(x,4);
x_dec=decimate(x,4);
x_int_down=interp(x_down,4);
x_int_dec=interp(x_dec,4);
X=abs(fft(x,N));
X_int_down=abs(fft(x_int_down,N));
X_int_dec=abs(fft(x_int_dec,N));
figure
subplot(3,1,1)
plot(w,repmat(X,1,2));grid;xlabel('w');ylabel('X(exp[jw])');
subplot(3,1,2)
plot(w,repmat(X_int_down,1,2));grid;xlabel('w');ylabel('X-int-down(exp[jw])');
subplot(3,1,3)
plot(w,repmat(X_int_dec,1,2));grid;xlabel('w');ylabel('X-int-dec(exp[jw])');

You might also like