MATLAB: Need help for these two commands

cat

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

Best Answer

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))
Related Question