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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!