Borrar filtros
Borrar filtros

Need help for explanation of one command

2 visualizaciones (últimos 30 días)
moonman
moonman el 23 de Sept. de 2011
This is part of code
x = zeros(size(y)); % Making a row vector x which is having length equal to y and all contents of x are 0.
*x(1:length(ADSR)) = ADSR;* %----> What this line is doing, I know it is padding zeros but what is logic for that

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 23 de Sept. de 2011
This is the code Walter provided in your previous question. It's a different way to do zero-padding.
Conventional Way: (assume ADSR is a 1xn vector)
x=ADSR; x=[ADSR,zeros(1,100)];
Walter's suggestion is to set x to be all zero first and then copy the value of ADSR to the beginning of x, that is what x(1:length(ADSR)) = ADSR does.
The potential issue is to make sure the length of x is bigger than the length of ADSR. Otherwise, x will end up with the same as ADSR.
  1 comentario
moonman
moonman el 23 de Sept. de 2011
thanks Jiang
then copy the value of ADSR to the beginning of x, that is what x(1:length(ADSR)) = ADSR does.
This is what i was looking for

Iniciar sesión para comentar.

Más respuestas (2)

Daniel Shub
Daniel Shub el 23 de Sept. de 2011
If ADSR is of length N and y is of length M, then at the end, x will have at least length N (and possibly length M) depending on if N is greater or less then M. Now as for why you might want to pad zeros on ADSR, you haven't provided nearly enough information.

Jan
Jan el 23 de Sept. de 2011
You know, what happens, and you ask, what the logic for it is. The question is not clear. Obvious any part in the program needs, that X contains the vector ADSR and some zeros to have the same length as y.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by