Signal analysis
Signal analysis
Assignment 1
ID: 21010530
1
Case 1
The resultant of two harmonics having different amplitudes
and the same frequencies
Code
clc,clear,clf
fs=1000;
t=0:1/fs:0.5;
x1=5*sin(150*t);
x2=19*sin(150*t);
x=x1+x2;
subplot(3,1,1)
plot(t,x1,'g',t,x2,'b')
xlabel('Time (sec)')
ylabel('Amplitude')
title('time domain')
legend('x1','x2')
axis([0 0.5 -30 30])
grid on
subplot(3,1,2)
plot(t,x,'r')
xlabel('Time (sec)')
ylabel('Amplitude')
title('time domain')
legend('x1')
axis([0 0.5 -30 30])
grid on
N=length(x);
freq=(0:N-1)/N*fs;
gt=abs(fft(x));
subplot(3,1,3)
plot(freq,gt,'r')
xlabel('frequency (HZ)')
ylabel('Amplitude')
title('frequency domain')
axis([0 60 0 1.5*max(gt)])
figure
2
Result
3
Case 2
Code
clc,clear,clf
fs=1000;
t=0:1/fs:6;
x1=5*sin(50*t);
x2=19*sin(52.5*t);
x=x1+x2;
subplot(3,1,1)
plot(t,x1,'y',t,x2,'b')
xlabel('Time (sec)')
ylabel('Amplitude')
title('time domain')
legend('x1','x2')
axis([0 1 -25 25])
grid on
subplot(3,1,2)
plot(t,x,'r')
xlabel('Time (sec)')
ylabel('Amplitude')
title('time domain')
legend('x1')
axis([0 6 -25 25])
grid on
N=length(x);
freq=(0:N-1)/N*fs;
gt=abs(fft(x));
subplot(3,1,3)
plot(freq,gt,'r')
xlabel('frequency (HZ)')
ylabel('Amplitude')
title('frequency domain')
grid on
axis([0 50 0 1.5*max(gt)])
figure
4
Result
5
Case 3
Code
fs=1000;
t=0:1/fs:4;
x1=5*sin(147*t);
x2=19*sin(80*t);
x=x1+x2;
subplot(2,1,1)
subplot(3,1,1)
plot(t,x1,'g',t,x2,'b')
xlabel('Time (sec)')
ylabel('Amplitude')
title('time domain')
legend('x1','x2')
axis([0 0.5 -30 30])
grid on
subplot(3,1,2)
plot(t,x,'r')
xlabel('Time (sec)')
ylabel('Amplitude')
title('time domain')
legend('x1')
axis([0 3 -30 30])
grid on
N=length(x);
freq=(0:N-1)/N*fs;
gt=abs(fft(x));
subplot(3,1,3)
plot(freq,gt,'r')
grid on
xlabel('frequency (HZ)')
ylabel('Amplitude')
title('frequency domain')
axis([0 50 0 1.2*max(gt)])
figure
6
Result
7
Case 4
The resultant of 10 harmonics with the same amplitudes
and different frequencies as follows: (⍵1, ⍵2 = 2⍵1, ⍵3 =
3⍵1, ... ⍵10 =10⍵1) rad/sec.
Code
fs=10000;
t=0:1/fs:2*pi;
w1=10;
x1=20*sin(w1*t);
x2=20*sin(2*w1*t);
x3=20*sin(3*w1*t);
x4=20*sin(4*w1*t);
x5=20*sin(5*w1*t);
x6=20*sin(6*w1*t);
x7=20*sin(7*w1*t);
x8=20*sin(8*w1*t);
x9=20*sin(9*w1*t);
x10=20*sin(10*w1*t);
x=x1+x2+x3+x4+x5+x6+x7+x8+x9+x10;
subplot(3,1,1)
plot(t,x1,'y',t,x2,'b',t,x3,'g',t,x4,'black',t,x5,'magenta')
xlabel('Time (sec)')
ylabel('Amplitude')
title('time domain')
legend('x1','x2','x3','x4','x5')
axis([0 1.5 -50 50])
grid on
subplot(3,1,2)
plot(t,x,'r')
xlabel('Time (sec)')
ylabel('Amplitude')
title('time domain')
legend('x')
axis([0 6 -200 200])
grid on
N=length(x);
freq=(0:N-1)/N*fs;
gt=abs(fft(x));
subplot(3,1,3)
plot(freq,gt,'r')
grid on
xlabel('frequency (HZ)')
8
ylabel('Amplitude')
title('frequency domain')
axis([0 20 0 1.2*max(gt)])
Figure
Result
9
Case 5
The resultant of 10 harmonics with different amplitudes
and different frequencies as follows: (⍵1, ⍵2 = 2⍵1, ⍵3 =
3⍵1, ... ⍵10 =10⍵1) rad/sec.
Code
fs=10000;
t=0:1/fs:4*pi;
w1=10;
x1=10*sin(w1*t);
x2=7*sin(2*w1*t);
x3=15*sin(3*w1*t);
x4=30*sin(4*w1*t);
x5=20*sin(5*w1*t);
x6=24*sin(6*w1*t);
x7=40*sin(7*w1*t);
x8=36*sin(8*w1*t);
x9=18*sin(9*w1*t);
x10=50*sin(10*w1*t);
x=x1+x2+x3+x4+x5+x6+x7+x8+x9+x10;
subplot(3,1,1)
plot(t,x1,'y',t,x2,'b',t,x3,'g',t,x4,'black',t,x5,'magenta')
xlabel('Time (sec)')
ylabel('Amplitude')
title('time domain')
legend('x1','x2','x3','x4','x5')
axis([0 1.5 -50 50])
grid on
subplot(3,1,2)
plot(t,x,'r')
xlabel('Time (sec)')
ylabel('Amplitude')
title('time domain')
legend('x')
axis([0 6 -400 400])
grid on
N=length(x);
freq=(0:N-1)/N*fs;
gt=abs(fft(x));
subplot(3,1,3)
10
plot(freq,gt,'r')
grid on
xlabel('frequency (HZ)')
ylabel('Amplitude')
title('frequency domain')
axis([0 20 0 1.2*max(gt)])
Figure
Result
11
Case 6
Code
fs=10000;
t=0:1/fs:3*pi;
x1=10*sin(100*t);
x2=15*sin(150*t);
x3=30*sin(153*t);
x4=40*sin(180*t);
x5=25*sin(200*t);
x6=50*sin(300*t);
x7=70*sin(480*t);
x8=75*sin(450*t);
x9=80*sin(400*t);
x10=100*sin(330*t);
x=x1+x2+x3+x4+x5+x6+x7+x8+x9+x10;
subplot(3,1,1)
plot(t,x1,'y',t,x2,'b',t,x3,'g',t,x4,'black',t,x5,'magenta')
xlabel('Time (sec)')
ylabel('Amplitude')
title('time domain')
legend('x1','x2','x3','x4','x5')
axis([0 1 -50 50])
grid on
subplot(3,1,2)
plot(t,x,'r')
xlabel('Time (sec)')
ylabel('Amplitude')
title('time domain')
legend('x')
axis([0 3 -500 500])
grid on
N=length(x);
freq=(0:N-1)/N*fs;
gt=abs(fft(x));
subplot(3,1,3)
plot(freq,gt,'r')
grid on
xlabel('frequency (HZ)')
12
ylabel('Amplitude')
title('frequency domain')
axis([0 100 0 1.1*max(gt)])
Figure
Result
13