Calculation of phase of signal

10 次查看(过去 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

采纳的回答

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 CenterFile Exchange 中查找有关 Matched 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