Anda di halaman 1dari 6

Joseph S.W.

13211043
TUGAS PENDAHULUAN
Fourier Series
t=(0:pi);
x=exp(-t/2);
No=32;
figure(1)
plot(x)
xlabel('t')
Xn=fft(x,No)/No;
Xn=[conj(Xn(No:-1:2)),Xn];
Xnmag=abs(Xn);
Xnangle=angle(Xn);
k=-No/2+1:No/2-1;
figure(2)
subplot(1,2,1)
subplot(2,1,1)
stem(k,Xnmag(No/2+1:length(Xn)-No/2));
xlabel('n')
ylabel('magnitude')
subplot(2,1,2)
stem(k,Xnangle(No/2+1:length(Xn)-No/2));
subplot(2,1,1)
subplot(2,1,2)
xlabel('n')
ylabel('angle')
Fourier Transform (1)
t=[-5:0.1:5];
fs=32;
x1=((t+1).*(t>=-1 & t<=0))+(1.*(t>0 & t<=1));
x2=(t.*(t>=0 & t<=1))+(1.*(t>1 & t<=2));
figure(1)
grid on
subplot(2,1,1)
plot(t,x1)
subplot(2,1,2)
plot(t,x2)
X1=fft(x1);
X1=fftshift(X1);
X1mag=abs(X1);
X1mag=X1mag/max(X1mag);
X1angle=angle(X1);
X1angle=X1angle/max(X1angle);
F1=[-length(X1)/2:(length(X1)/2)-1]*fs/length(X1);
X2=fft(x2);
X2=fftshift(X2);
X2mag=abs(X2);
X2mag=X2mag/max(X2mag);

X2angle=angle(X2);
X2angle=X2angle/max(X2angle);
F2=[-length(X2)/2:(length(X2)/2)-1]*fs/length(X2);
figure(2)
grid on
subplot(2,2,1)
plot(F1,X1mag);
xlabel('n')
ylabel('magnitude')
subplot(2,2,2)
plot(F1,X1angle);
xlabel('n')
ylabel('angle')
subplot(2,2,3)
plot(F2,X1mag);
xlabel('n')
ylabel('magnitude')
subplot(2,2,4)
plot(F1,X1angle);
xlabel('n')
ylabel('angle')
Fourier Transform (2)
t=[-5:0.1:5];
fs=32;
x1=((1).*(t>=-3 & t<=3));
x2=((1).*(t>=-1 & t<=1));
figure(1)
grid on
subplot(2,1,1)
plot(t,x1)
subplot(2,1,2)
plot(t,x2)
X1=fft(x1);
X1=fftshift(X1);
X1mag=abs(X1);
X1mag=X1mag/max(X1mag);
X1angle=angle(X1);
X1angle=X1angle/max(X1angle);
F1=[-length(X1)/2:(length(X1)/2)-1]*fs/length(X1);
X2=fft(x2);
X2=fftshift(X2);
X2mag=abs(X2);
X2mag=X2mag/max(X2mag);
X2angle=angle(X2);
X2angle=X2angle/max(X2angle);
F2=[-length(X2)/2:(length(X2)/2)-1]*fs/length(X2);

figure(2)
grid on
subplot(2,2,1)
plot(F1,X1mag);
xlabel('n')
ylabel('magnitude')
subplot(2,2,2)
plot(F1,X1angle);
xlabel('n')
ylabel('angle')
subplot(2,2,3)
plot(F2,X1mag);
xlabel('n')
ylabel('magnitude')
subplot(2,2,4)
plot(F1,X1angle);
xlabel('n')
ylabel('angle')
Amplitude Modulation (1)
fc=20000;
po=0;
ts=1/(10*fc);
t=[0:200]*ts;
x=cos(2*pi*2000*t);
y=x.*(cos(2*pi*fc*t));
w=y.*(cos((2*pi*fc*t)+(po)));
n=5;
[num,den]=butter(n,(2*fc*ts));
v=filter(num,den,w);
figure(1)
subplot(2,2,1)
plot(x)
subplot(2,2,2)
plot(y)
subplot(2,2,3)
plot(w)
subplot(2,2,4)
plot(v)
Amplitude Modulation (2)
fc=20000;
po=pi/2;
ts=1/(10*fc);
t=[0:200]*ts;
x=cos(2*pi*2000*t);
y=x.*(cos(2*pi*fc*t));
w=y.*(cos((2*pi*fc*t)+(po)));
n=5;
[num,den]=butter(n,(2*fc*ts));
v=filter(num,den,w);
figure(2)

subplot(2,2,1)
plot(x)
subplot(2,2,2)
plot(y)
subplot(2,2,3)
plot(w)
subplot(2,2,4)
plot(v)
Amplitude Modulation (3)
fc=20000;
po=pi;
ts=1/(10*fc);
t=[0:200]*ts;
x=cos(2*pi*2000*t);
y=x.*(cos(2*pi*fc*t));
w=y.*(cos((2*pi*fc*t)+(po)));
n=5;
[num,den]=butter(n,(2*fc*ts));
v=filter(num,den,w);
figure(3)
subplot(2,2,1)
plot(x)
subplot(2,2,2)
plot(y)
subplot(2,2,3)
plot(w)
subplot(2,2,4)
plot(v)
Amplitude Modulation (4)
fc=20000;
po=pi/2;
ts=1/(10*fc);
t=[0:200]*ts;
x=cos(2*pi*2000*t);
y=x.*(cos(2*pi*fc*t));
w=y.*(cos((2*pi*fc*t)+(po)));
n=5;
[num,den]=butter(n,(2*fc*ts));
v=filter(num,den,w);
figure(2)
subplot(2,2,1)
plot(x)
subplot(2,2,2)
plot(y)
subplot(2,2,3)
plot(w)
subplot(2,2,4)
plot(v)

Amplitude Modulation (5)


fc=20000;
po=0;
ts=1/(10*fc);
t=[0:200]*ts;
x=cos(2*pi*2000*t);
u = 0.5;
Ac = 4;
y = Ac*(1+ u*pi.*x).*cos(2*pi*fc*t);
y1=abs(y);
n=5;
[num,den]=butter(n,(2*fc*ts));
w=filter(num,den,y1);
v=w-mean(w);
figure(1)
subplot(2,2,1)
plot(y);
subplot(2,2,2)
plot(y1);
subplot(2,2,3)
plot(w);
subplot(2,2,4)
plot(v);
Amplitude Modulation (6)
fc=20000;
po=0;
ts=1/(10*fc);
t=[0:200]*ts;
x=cos(2*pi*2000*t);
u = 1.2;
Ac = 4;
y = Ac*(1+ u*pi.*x).*cos(2*pi*fc*t);
y1=abs(y);
n=5;
[num,den]=butter(n,(2*fc*ts));
w=filter(num,den,y1);
v=w-mean(w);
figure(1)
subplot(2,2,1)
plot(y);
subplot(2,2,2)
plot(y1);
subplot(2,2,3)
plot(w);
subplot(2,2,4)
plot(v);
Frequency Modulation (1)
fc=100;
ts=1/(10*fc);
t=[0:1000]*ts;
x=sin(2*pi*t);

fs=1000;
kf=160*pi;
y=fmmod(x,fc,fs,kf);
Ymag=abs(y);
F=[-length(y)/2:(length(y)/2)-1]*1000/length(y);
plot(F,Ymag);
w=fmdemod(y,fc,fs,kf);
v=w-mean(w);
plot(v);
figure(1)
subplot(2,2,1)
plot(x);
subplot(2,2,2)
plot(y);
subplot(2,2,4)
plot(F,Ymag);
figure(2)
subplot(2,1,1)
plot(v);
subplot(2,1,2)
plot(w);
Frequency Modulation (2)
fc=250;
ts=1/(10*fc);
t=[-0.1:ts:0.1];
x=sinc(100*pi*t);
fs=1000;
kf=200*pi;
y=fmmod(x,fc,fs,kf);
Ymag=abs(y);
F=[-length(y)/2:(length(y)/2)-1]*1000/length(y);
plot(F,Ymag);
w=fmdemod(y,fc,fs,kf);
v=w-mean(w);
plot(v);
figure(1)
subplot(2,2,1)
plot(x);
subplot(2,2,2)
plot(y);
subplot(2,2,4)
plot(F,Ymag);
figure(2)
subplot(2,1,1)
plot(v);
subplot(2,1,2)
plot(w);

Anda mungkin juga menyukai