Correct phase of sine wave based on phase difference?

1 view (last 30 days)
Hello Everyone,
I have the following sample code:
clear all; close all; clc; %#ok
%%Sine Wave Generation: (including Time Domain plots)
fs = 40e6; % Sampling frequency (samples per second)
dt = 1/fs; % seconds per sample
StopTime = 0.0001; % seconds
t = (0:dt:StopTime-dt)';
F = 15e6; % Sine wave frequency (hertz)
ChannelA = sin(2*pi*F*t+0.61348323)';
ChannelB = sin(2*pi*F*t + 0.75310957)'; % Phase Difference should be 0.1396
%%N - Point FFT
N = 64;
XA = fftshift(fft(ChannelA,N));
XB = fftshift(fft(ChannelB,N));
dF = fs/N; % hertz
f = -fs/2:dF:fs/2-dF; % hertz
%%Phase Calculations for N-point FFT:
[Max_xA,index1] = max(abs(XA));
[Max_xB,index2] = max(abs(XB));
complex_xA = XA(index1); phase1 = (angle(complex_xA));
complex_xB = XB(index2); phase2 = (angle(complex_xB));
Phase_Difference = abs(phase1 - phase2);
Now, I would like to correct either of my Channels with the Phase difference calculated so that Channel A will have same phase as Channel B. Can someone help me on how should I do this in matlab
Thanks in advance, Mounika

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!