In: Computer Science
Example: Consider a signal sampled at 1.2 kHz which is
composed of 50HZ, 90HZ and 150HZ of sine waves, having amplitudes
of 5V, 3V and 2V respectively .
Write a MATLAB program to plot signal in time domain as well as in
frequency domain to get information about major frequency
components present in the signal.
From the given three signals, the original signal which is sampled is found by adding them.
The sum of signals and given three signals are plotted against time (Time domain).
Then the plots of Amplitudes and Power against frequecy are also plotted, which shows the information about the major frequency component present in the signal.
The major frequency component present in the signal is found as 50 Hz.
The code and screenshots of results are shown below.
Matlab code with explanations:
A1=5; A2=3;A3=2; % Amplitudes
f1=50; f2=90; f3=150; % Frequencies
Fs=1200; %Samplinf frequency
t=0:1/Fs:0.2; % Time scale for plotting the signals
x1=A1*sin(2*pi*f1*t); x2=A2*sin(2*pi*f2*t); x3=A3*sin(2*pi*f3*t); %
%Signals
X=x1+x2+x3; % Sum of x1,x2 and x3
plot(t,X)
title('Original signal being sampled')
figure
plot (t,x1,t,x2,t,x3)
title('Composition of original signal')
n=length(X); % they all have the same length ..
Y=fft(X); % Obtain Fourier transform
f = (0:n-1)*(Fs/n);% Frequency scale
figure
plot(f,abs(Y)) % Spectrum
title('Spectrum')
xlabel('Frequncy (Hz)');
ylabel('Voltage (V)');
power = abs(Y).^2/n; % power of the DFT
figure
plot(f,power) % Power spectrum
title('Power')
xlabel('Frequency')
ylabel('Power')
Screenshots: