필터 지우기
필터 지우기

Need help for these two commands

조회 수: 4 (최근 30일)
moonman
moonman 2011년 9월 22일
These are two lines
dif = length(sig) - length(ADSR);
x = cat(2, ADSR, zeros(1,dif));
What is purpose of zeros(1,dif) Plz explain

채택된 답변

Wayne King
Wayne King 2011년 9월 22일
It is appending (padding) zeros on the end of ADSR so that the total length of x is the length of the signal, sig:
length(ADSR)+ (length(sig)-length(ADSR))

추가 답변 (2개)

Fangjun Jiang
Fangjun Jiang 2011년 9월 22일
It creates a 1 by dif matrix and all its value is zero.
cat(2, ADSR, zeros(1,dif)) is the same as [ADSR, zeros(1,dif)]
I want to give a caution on using function length().
LENGTH(X) returns the length of vector X. It is equivalent
to MAX(SIZE(X)) for non-empty arrays and 0 for empty ones.

Walter Roberson
Walter Roberson 2011년 9월 22일
The code is constructing a vector that pads ADSR with 0s to be the same length as sig is.
Another way of doing this would be:
x = zeros(size(sig));
x(1:length(ADSR)) = ADSR;

카테고리

Help CenterFile Exchange에서 Hilbert and Walsh-Hadamard Transforms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by