MATLAB: General Binomial Matrix Manipulation

MATLABmatrixmatrix manipulation

Let's say I have a matrix of the form:
Starting from this matrix, I would like to calculate a new matrix, in a time efficient way:
The algorithm, which I am looking for, should also work for a matrix of the form:
Does someone know how this algorithm could look like?
Best
Alex

Best Answer

[m,n]=size(Astart);
B=reshape(Astart,m,1,n).*Astart;
Aend=reshape(B,m,[]);