delay signal by 'n' samples

Suppose I have a wav signal and want to delay it in matlab by 'n' number of samples, could someone please tell me how I could do it?
Thanks in advance

 Respuesta aceptada

Pablo López
Pablo López el 18 de Jul. de 2019

2 votos

You should use the next command:
shifted_data = delayseq(data,DELAY)
You must notice that data must be a column vector or it won't work and you should specify in DELAY the number of samples you want to delay your signal. Here you have more information.
Hope that helps!

5 comentarios

Walter Roberson
Walter Roberson el 18 de Jul. de 2019
Using delayseq() has the advantage of permitting non-integer delays. And of course it saves you from having to write your own code.
ARHUM AHMAD
ARHUM AHMAD el 21 de Dic. de 2019
it does'nt work properly
Walter Roberson
Walter Roberson el 21 de Dic. de 2019
What difficulty did you have? Was there an error message?
Sri Harsha Palepu
Sri Harsha Palepu el 5 de Abr. de 2021
Can this be used to sine wave also
Walter Roberson
Walter Roberson el 5 de Abr. de 2021
delayseq() from the Phased Array Toolbox can be used for real or complex vectors, or for real or complex 2D matrices in which each column is to be treated as a channel.
The thing to remember about delayseq() is that it works on arrays, not on some modeled underlying signal form. So it does not care whether the data happens to represent a sine wave -- if you ask to delay by two sample time then it is just going to fill in two 0's.
delayseq() is not suitable for the case where you are modeling a signal that is intended to have existed indefinitely in the past, and for which you want to do a phase change, with the intention being that the initial data will be "filled in" with whatever part of the signal would have existed in the past but in theory got delayed to the present.

Iniciar sesión para comentar.

Más respuestas (3)

Walter Roberson
Walter Roberson el 15 de Nov. de 2011

0 votos

delayed_signal = [zeros(1,n) original_signal];
Unless that is, the signal is a column vector, in which case
delayed_signal = [zeros(n, size(original_signal,2)); original_signal];

1 comentario

Padma
Padma el 15 de Nov. de 2011
i am not getting the correct delay, when i am measuring it using xcorr in my program

Iniciar sesión para comentar.

Wayne King
Wayne King el 15 de Nov. de 2011

0 votos

Why? Seems to me that the way Walter gave you works.
original_signal = randn(10,1);
n = 5;
delayed_signal = [zeros(n,1) ; original_signal];
[c,lags] = xcorr(delayed_signal,original_signal);
stem(lags,c);
[~,maxlag] = max(c);
fprintf('Signal is delayed %d samples\n',lags(maxlag));
Jannatul Ferdous
Jannatul Ferdous el 30 de En. de 2019

0 votos

x=[1 2 3 4];
subplot(3,1,1);
stem(x);
title('X');
y=[1 1 1 1];
subplot(3,1,2);
stem(y);
title('Y');
z=x+y;
subplot(3,1,3);
stem(z);
title('Z=X+Y');

Categorías

Etiquetas

Preguntada:

el 15 de Nov. de 2011

Comentada:

el 5 de Abr. de 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by