if i have two vectors that result in a matrix that is 40x5 but i want the dimensions flipped, how would i do that

1 回表示 (過去 30 日間)
TAPAN DARJI
TAPAN DARJI 2017 年 1 月 30 日
再開済み: Stephen23 2021 年 8 月 22 日
i have a vectors z and y when i multiply them i get a 40*5 matrix. however want a 5*40 matrix. how do i get the 5*40 matrix

回答 (3 件)

Jan
Jan 2017 年 1 月 30 日
x = 1:40;
y = 1:5;
M = y.' * x

Stephen23
Stephen23 2017 年 1 月 30 日
編集済み: Stephen23 2017 年 1 月 30 日
You can use transpose:
M.'
where M is the matrix.

John BG
John BG 2017 年 1 月 30 日
if
size(z)
=
5 5
size(y)
=
5 40
then
size(z*y)
=
5 40
and
size(y'*z')
=
40 5
if you are using element wise product
.*
then if
size(z)
=
1 40
size(y)
=
1 5
then
size(z.'*y)
=
40 5
size(y.'*z)
=
5 40
if you find this answer useful would you please be so kind to mark my answer as Accepted Answer?
thanks in advance
John BG
  3 件のコメント
John BG
John BG 2017 年 3 月 16 日
this question already had my answer marked as accepted answer. The question originator marked my answer as the best answer supplied.
My answer comprises the common ways to multiply 2 vectors within the conditions mention in the question.
John BG
Jan
Jan 2017 年 3 月 16 日
編集済み: Jan 2017 年 3 月 20 日
No, John, your claim that it was the author of the question is wrong and flimsy. You have accepted this answer the first time and you did this again now. You know that your self-accepting is recorded in the "Recent Activity" list and you ignore that all users can read this.
Screenshot taken 25.02.2017 19:15 UTC:
Massive self-accepting is against the idea of this forum and in addition it is bad for your reputation (apart from the points): Who will trust your accepted answers when it is known, that you tend to accept them by your own? This forum is not a platform for chasing credits. Matlab is not Minecraft.

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by