How to move a Signal..
Afficher commentaires plus anciens
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 commentaire
Aboubakar Tchendjou
le 16 Fév 2022
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
Réponse acceptée
Plus de réponses (1)
Nitin
le 12 Août 2011
1 vote
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.
Catégories
En savoir plus sur Measurements and Feature Extraction dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!