Professional Documents
Culture Documents
Task 1
Task 2
Task 3
Task 4
clc; clear;
Task 1
m=exp(-100*abs(t));
c=cos(2*pi*1000*t);
%perform the multiplication
g=m.*c;
%perform full-wave rectification
y=abs(g);
m=2 + sin(2*pi*1000*t);
c=cos(2*pi*10^4*t);
%perform the multiplication
g=m.*c;
%perform full-wave rectification
y=abs(g);
m=sin(2*pi*100*t);
c=cos(2*pi*1000*t);
%perform the multiplication
g=m+c;
%perform full-wave rectification
y=(g);
% ts=0.00001;
% t=-0.1:ts:0.1;
% fc=1000;
fs=100*1000;
t=-0.1:(1/(fs-1)):1;
% Define functions
wc=2*pi*1000;
m=2+sin(2*pi*100*t);
c=cos(2*pi*1000*t);
% perform Multiplication
g=m.*c;
% full wave rectification
y=abs(g);
% filter
w0=(4/pi)*(cos(wc*t)-1/3*cos(3*wc*t)+1/5*cos(5*wc*t));
cutoff=150;
D=(g.*w0);
[a ,b]=butter(5,2*cutoff*(1/fs),'low');
% output after filter
z=filter(a,b,D);
% plot input & output on same graph
figure(7)
plot(t,m,t,z);
legend('Input signal','output signal')
xlabel('time')
ylabel('amplitude')
title('example');
% finding FT of signals
M=abs(fftshift(fft(m)));
J=abs(fftshift(fft(D)));
G=abs(fftshift(fft(g)));
Y=abs(fftshift(fft(y)));
Z=abs(fftshift(fft(z)));
C=abs(fftshift(fft(c)));
% creating vector
% f=(-length(t)/2:length(t)/2-1)/(length(t)*ts);
f=(-fs/2:(fs/(length(m)-1)):(fs/2));
% % one screen plot
figure(8)
subplot(221)
plot(f,M)
title('Massy signal')
subplot(222)
plot(f,C)
title('Carrier signal')
subplot(223)
plot(f,Y)
title('After addition')
subplot(224)
plot(f,Z)
title('Filtered signal')
plot(f,Z)
Published with MATLAB® R2014a