Calculation of phase of signal

9 ビュー (過去 30 日間)
Omkar Vaze
Omkar Vaze 2021 年 12 月 13 日
編集済み: Chunru 2021 年 12 月 30 日
I have generated two signals with two different frequencies keeping the amplitude same for both signals. The signals are shown in below
image.
As seen in the figure there is gap between first signal(blue) and second signal(red). I am trying to remove this gap by adjusting the phase of second signal. But I am not able to calculate the phase difference between these two signals. I am trying to write a code in which it will calculate the phase of next signal by itself and join the signals together.
The equation I used to generate the signal is
x=sin(2*pi*f*t +phase);
All suggestions are welcome. Thank you in advance
  1 件のコメント
yanqi liu
yanqi liu 2021 年 12 月 30 日
yes,sir,my be just use cat to merge vector

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

採用された回答

Chunru
Chunru 2021 年 12 月 30 日
編集済み: Chunru 2021 年 12 月 30 日
fs = 50;
ns1 = 200; % samples for x1
f1 = 1;
x1 = sin(2*pi*f1*(0:ns1-1)/fs); % first part
% Try to make the fist point of x2 close to last point of x1
x20 = sin(2*pi*f1*ns1/fs);
% This is to say the phase for x2:
phi2 = 2*pi*f1*ns1/fs;
% To make x1 and x2 connected without gap
% phi2 = 2*pi*f1*(ns1-1)/fs;
% but this will give a flat signal between ns1 and ns1+1
ns2 = 300;
f2 = 0.5;
x2 = sin(2*pi*f2*(0:ns2-1)/fs + phi2);
figure;
plot((0:ns1-1)/fs, x1); hold on
plot((ns1+(0:ns2-1))/fs, x2);
figure;
plot((0:ns1+ns2-1)/fs, [x1 x2])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatched Filter and Ambiguity Function についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by