Correct phase of sine wave based on phase difference?

1 回表示 (過去 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
  1 件のコメント
mounika
mounika 2018 年 7 月 31 日
any insights will be appreciated! Thanks

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeDigital Filter Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by