필터 지우기
필터 지우기

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 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