Need help for explanation of one command
조회 수: 2 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
채택된 답변
Fangjun Jiang
2011년 9월 23일
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.
추가 답변 (2개)
Daniel Shub
2011년 9월 23일
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.
댓글 수: 0
Jan
2011년 9월 23일
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.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!