You are on page 1of 13

Assignment 1 signal analysis

Name: Abanoub Adel Khalaf

ID:20010003

Group: 2

Sec: 9
1) The resultant of two harmonics having different amplitudes and
the same frequencies.
CODE
%time domain
dt=.0001
t=0:dt:1
a1=10
a2=20
f1=15
f2=15
x1=a1*sin(2*pi*f1*t)
x2=a2*sin(2*pi*f2*t)
x_res=x1+x2
subplot(2,1,1)
plot(t,x1,'--r',t,x2,'--m',t,x_res,'k')
xlabel('Time')
ylabel('Displacement')
title('Q1 time domain')
legend('x1','x2','x_res')
%frec domain
fs=1/dt
N=length(t)
f=(0:N-1)*(fs/N)
xf_res=abs(fft(x_res));%fast fourier transform
subplot(2,1,2)
plot(f,xf_res)
xlabel('frequency')
ylabel('amplitude')
title('Q1 frequency domain')
legend('xf_res')
axis([0 150 0 max(xf_res)])
graph 1
2) The resultant of two harmonics having different amplitudes and
the first frequency is very close to the second frequency (⍵𝟏 ≈
⍵𝟐).
CODE
%time domain
dt=.0001
t=0:dt:1
a1=7
a2=10
f1=14.5
f2=15
x1=a1*sin(2*pi*f1*t)
x2=a2*sin(2*pi*f2*t)
x_res=x1+x2
subplot(2,1,1)
plot(t,x1,'--r',t,x2,'--m',t,x_res,'k')
xlabel('Time')
ylabel('Displacement')
title('Q2 time domain')
legend('x1','x2','x_res')
%frec domain
fs=1/dt
N=length(t)
f=(0:N-1)*(fs/N)
xf_res=abs(fft(x_res));%fast fourier transform
subplot(2,1,2)
plot(f,xf_res)
xlabel('frequency')
ylabel('amplitude')
title('Q2 frequency domain')
legend('xf_res')
axis([0 300 0 max(xf_res)])
graph 2
3) The resultant of two harmonics having different amplitudes and
different frequencies (⍵𝟏 ≫ ⍵𝟐)
Code
%time domain
dt=.0001
t=0:dt:.5
a1=10
a2=6
f1=40
f2=10
x1=a1*sin(2*pi*f1*t)
x2=a2*sin(2*pi*f2*t)
x_res=x1+x2
subplot(2,1,1)
plot(t,x1,'--r',t,x2,'--B',t,x_res,'k')
xlabel('Time')
ylabel('Displacement')
title('Q3 time domain')
legend('x1','x2','x_res')
%frec domain
fs=1/dt
N=length(t)
f=(0:N-1)*(fs/N)
xf_res=abs(fft(x_res));%fast fourier transform
subplot(2,1,2)
plot(f,xf_res)
xlabel('frequency')
ylabel('amplitude')
title('Q3 frequency domain')
legend('xf_res')
axis([0 100 0 1.1*max(xf_res)])
graph 3
4) The resultant of 10 harmonics with the same amplitudes and
different frequencies as follows: (⍵𝟏, ⍵𝟐 = 𝟐⍵𝟏, ⍵𝟑 = 𝟑⍵𝟏, … … .
⍵𝟏𝟎 = 𝟏𝟎⍵𝟏 ) 𝒓𝒂𝒅/𝒔𝒆𝒄.
Code
%time domain
dt=.0001
t=0:dt:.5
a1=20
a2=20
a3=20
a4=20
a5=20
a6=20
a7=20
a8=20
a9=20
a10=20
f1=10
f2=20
f3=30
f4=40
f5=50
f6=60
f7=70
f8=80
f9=90
f10=100
x1=a1*sin(2*pi*f1*t)
x2=a2*sin(2*pi*f2*t)
x3=a3*sin(2*pi*f3*t)
x4=a4*sin(2*pi*f4*t)
x5=a5*sin(2*pi*f5*t)
x6=a6*sin(2*pi*f6*t)
x7=a7*sin(2*pi*f7*t)
x8=a8*sin(2*pi*f8*t)
x9=a9*sin(2*pi*f9*t)
x10=a10*sin(2*pi*f10*t)
x_res=x1+x2+x3+x4+x5+x6+x7+x8+x9+x10
subplot(2,1,1)
plot(t,x1,'--r',t,x2,'--B',t,x3,'--y',t,x4,'--g',t,x5,'--r',t,x6,'--r',t,x7,'--
B',t,x8,'--g',t,x9,'--m',t,x10,'--m',t,x_res,'k')
xlabel('Time')
ylabel('Displacement')
title('Q4 time domain')
legend('x1','x2','x3','x4','x5','x6','x7','x8','x9','x10','x_res')
%frec domain
fs=1/dt
N=length(t)
f=(0:N-1)*(fs/N)
xf_res=abs(fft(x_res));%fast fourier transform
subplot(2,1,2)
plot(f,xf_res)
xlabel('frequency')
ylabel('amplitude')
title('Q4 frequency domain')
legend('xf_res')
axis([0 100 0 1.1*max(xf_res)])

graph 4
5) The resultant of 10 harmonics with different amplitudes and
different frequencies as follows: (⍵𝟏, ⍵𝟐 = 𝟐⍵𝟏, ⍵𝟑 = 𝟑⍵𝟏, … …
. ⍵𝟏𝟎 = 𝟏𝟎⍵𝟏 ) 𝒓𝒂𝒅/𝒔𝒆c.

Code
%time domain
dt=.0001
t=0:dt:.5
a1=5
a2=10
a3=15
a4=20
a5=25
a6=30
a7=35
a8=40
a9=45
a10=50
f1=10
f2=20
f3=30
f4=40
f5=50
f6=60
f7=70
f8=80
f9=90
f10=100
x1=a1*sin(2*pi*f1*t)
x2=a2*sin(2*pi*f2*t)
x3=a3*sin(2*pi*f3*t)
x4=a4*sin(2*pi*f4*t)
x5=a5*sin(2*pi*f5*t)
x6=a6*sin(2*pi*f6*t)
x7=a7*sin(2*pi*f7*t)
x8=a8*sin(2*pi*f8*t)
x9=a9*sin(2*pi*f9*t)
x10=a10*sin(2*pi*f10*t)
x_res=x1+x2+x3+x4+x5+x6+x7+x8+x9+x10
subplot(2,1,1)
plot(t,x1,'--r',t,x2,'--b',t,x3,'--m',t,x10,'--g',t,x_res,'k')
xlabel('Time')
ylabel('Displacement')
title('Q5 time domain')
legend('x1','x2','x3','x10','x_res')
%frec domain
fs=1/dt
N=length(t)
f=(0:N-1)*(fs/N)
xf_res=abs(fft(x_res));%fast fourier transform
subplot(2,1,2)
plot(f,xf_res)
xlabel('frequency')
ylabel('amplitude')
title('Q5 frequency domain')
legend('xf_res')
axis([0 100 0 1.1*max(xf_res)])

graph 5
6) The resultant of 10 harmonics with different amplitudes and
different frequencies randomly.
Code
%time domain
dt=.0001
t=0:dt:.25
a1=5
a2=12
a3=20
a4=27
a5=32
a6=39
a7=47
a8=26
a9=17
a10=80
f1=10
f2=18
f3=32
f4=5
f5=66
f6=58
f7=83
f8=96
f9=101
f10=135
x1=a1*sin(2*pi*f1*t)
x2=a2*sin(2*pi*f2*t)
x3=a3*sin(2*pi*f3*t)
x4=a4*sin(2*pi*f4*t)
x5=a5*sin(2*pi*f5*t)
x6=a6*sin(2*pi*f6*t)
x7=a7*sin(2*pi*f7*t)
x8=a8*sin(2*pi*f8*t)
x9=a9*sin(2*pi*f9*t)
x10=a10*sin(2*pi*f10*t)
x_res=x1+x2+x3+x4+x5+x6+x7+x8+x9+x10
subplot(2,1,1)
plot(t,x1,'--r',t,x2,'--b',t,x3,'--m',t,x10,'--g',t,x_res,'k')
xlabel('Time')
ylabel('Displacement')
title('Q6 time domain')
legend('x1','x2','x3','x10','x_res')
%frec domain
fs=1/dt
N=length(t)
f=(0:N-1)*(fs/N)
xf_res=abs(fft(x_res));%fast fourier transform
subplot(2,1,2)
plot(f,xf_res)
xlabel('frequency')
ylabel('amplitude')
title('Q6 frequency domain')
legend('xf_res')
axis([0 100 0 1.1*max(xf_res)])

graph 6

You might also like