필터 지우기
필터 지우기

How to move a Signal..

조회 수: 4 (최근 30일)
Susan
Susan 2011년 8월 12일
댓글: Aboubakar Tchendjou 2022년 2월 16일
Dear all,
I am trying to learn some concepts of Signal processing to be able to work on my project. For the sample code below (Not my code but the idea is the same, mine is using random number generator), I have two signals and one is a delayed version of first one.. I want to know how can I move the Signal by the delay time I got so I will show that the two signals are the same indeed but one is delayed?
n = 0:299;
x = cos(pi/4*n);
xdft = fft(x);
k = 0:299;
D = 2;
phaseshift = exp(-1j*(2*pi*k*D)/length(x));
xdft = phaseshift.*xdft
% y is x delayed by two samples
y = ifft(xdft,'symmetric');
[Pxy,W] = cpsd(x,y,100,80,128);
[~,I] = max(abs(Pxy));
phase = atan2(-imag(Pxy(I)),real(Pxy(I)));
% the delay in samples prints out. The negative indicates delay.
round(phase*(1/(pi/4)))
plot(x(1:100),'k');
hold on;
plot(y(1:100),'b');
grid on; legend('Original','Delayed');
Thanks,
  댓글 수: 1
Aboubakar Tchendjou
Aboubakar Tchendjou 2022년 2월 16일
Hallo zusammen
wie kann ich bitte ein Signal x[n]=2delta[n]+delta[n-2]+4delta[n-5]
3 Mal nach recht mit Matlab verschien also X[n-3] Mit Matlab erzeugen?
Danke im Voraus

댓글을 달려면 로그인하십시오.

채택된 답변

Daniel Shub
Daniel Shub 2011년 8월 12일
For delays that are an integer number of samples you can add a delay (zeros) in the plot:
plot([zeros(1, D), x(1:100)],'k');
plot([y(1:100), zeros(1, D)],'b');
For delays that are not an integer number of samples, where using your approach with "phaseshift" really shines, you really have to just rerun your code backwards to compensate for the delay.

추가 답변 (1개)

Nitin
Nitin 2011년 8월 12일
It may be that I didn't understand your problem but isn't plot((1-delay:100-delay),x(1:100)) plot a delayed version of x on the same scale; here I've used 1-delay, as I saw you're plotting x and y with an initial time of 1. The delay you've calculate in your code is -2. The values for time periods before the delay time are not defined, but you could define them with some initial value.

카테고리

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