How to move a Signal..
古いコメントを表示
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
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
採用された回答
その他の回答 (1 件)
Nitin
2011 年 8 月 12 日
1 投票
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.
カテゴリ
ヘルプ センター および File Exchange で Transforms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!