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 件のコメント

Akira Agata
Akira Agata 2019 年 9 月 3 日
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?
Alexander Pakakis
Alexander Pakakis 2019 年 9 月 3 日
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

サインインしてコメントする。

 採用された回答

Matt J
Matt J 2019 年 9 月 3 日
編集済み: Matt J 2019 年 9 月 3 日

1 投票

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

1 件のコメント

Alexander Pakakis
Alexander Pakakis 2019 年 9 月 3 日
works perfectly!
Thank you Matt!

サインインしてコメントする。

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2019 年 9 月 3 日
編集済み: Andrei Bobrov 2019 年 9 月 3 日

1 投票

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

1 件のコメント

Alexander Pakakis
Alexander Pakakis 2019 年 9 月 3 日
works perfectly!
Thank you Andrei!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Operating on Diagonal Matrices についてさらに検索

製品

リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by