function alpha=cummom(h) alpha = zeros(1,length(h)); convolved = zeros(length(h),length(h)+1); convolved(:,1) = 1;%initial condition needed for (n=1:length(h)) %n corresponds to the moment number we calculate sum2 = 0; for (l=1:n) sum2 = sum2 + convolved(l,n-l+1) * h(l); end alpha(n) = sum2; convolved(1,n+1) = sum2; for (k=2:length(h)) sum3 = 0; for (l=1:(n+1)) sum3 = sum3 + convolved(k-1,l) * convolved(1,n+2-l); end convolved(k,n+1) = sum3; end end