How do I calculate the amplitude ratio and phase lag for two sinusoidal signals in MATLAB?
How do I calculate the amplitude ratio and phase lag for two sinusoidal signals in MATLAB?
NOTE:-
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
The amplitude ratio and phase lag for two sinusoidal signals can be determined by taking the Fourier Transform and comparing the magnitude and phase of the signals.
For example:
% clear
clear all% set the lag
lag = pi/2;% amplitude for sinusodial 1
amp_x = 2;% amplitude for sinusodial 2
amp_y = 4;% Sampling frequency
Fs = 1024;% Time vector of 0.5 second
t = 0:1/Fs:0.5*(Fs-1)/Fs;% number of points
npts = length(t);% Create a sine wave of 20 Hz.
x = amp_x * (sin(2*pi*t*20) + ...
0.25*randn(1,npts)) + 5;% Create a sine wave of 20 Hz
% with a phase of pi/2.
y = amp_y * (sin(2*pi*t*20 + lag)...
+ 0.25*randn(1,npts));% remove bias
x = x - mean(x);
y = y - mean(y);% plot the signal
figure(1)
plot(t,x,t,y);
xlabel('Time (s)');
ylabel('Amplitude');
legend('Signal x(t):sin(2*pi*t*20)',...
'Signal y(t):sin(2*pi*t*20+lag)');% take the FFT
X=fft(x);
Y=fft(y);
SEE COMPLETE ANSWER CLICK THE LINK