MATLAB Answers

0

General Binomial Matrix Manipulation

Asked by Alexander Pakakis on 3 Sep 2019
Latest activity Commented on by Alexander Pakakis on 3 Sep 2019
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

  2 Comments

Assuming Astart is n-by-2 array, straight-forward way to calculate Aend would be:
Aend = [Astart(:,1).^2 Astart(:,1).*Astart(:,2) Astart(:,2).*Astart(:,1) Astart(:,2).^2];
But it's not clear for me what Aend looks like when Astart is n-by-m array.
Could you explain more detail on this?
of course, I can explain more!
Let's say I have:
then I would like to calculate this matrix:
I think, you will understand the system when see this table:
Example.JPG

Sign in to comment.

Products


Release

R2018b

2 Answers

Answer by Matt J
on 3 Sep 2019
Edited by Matt J
on 3 Sep 2019
 Accepted Answer

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

  1 Comment

works perfectly!
Thank you Matt!

Sign in to comment.


Answer by Andrei Bobrov
on 3 Sep 2019
Edited by Andrei Bobrov
on 3 Sep 2019

Aend = reshape(Abegin.*permute(Abegin,[1,3,2]),size(Abegin,1),[]);

  1 Comment

works perfectly!
Thank you Andrei!

Sign in to comment.