Correct phase of sine wave based on phase difference?

조회 수: 4 (최근 30일)
mounika
mounika 2018년 7월 27일
편집: mounika 2018년 8월 1일
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);
display(Phase_Difference);
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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by