A question about product operation

3 ビュー (過去 30 日間)
Dan P
Dan P 2013 年 9 月 16 日
Hello all!
I'm not sure if this was explained before, but I could not find any answer to this.
So, if i have x=[a b c] and y=[d e f] I'd like to know (if it's possible) how I could obtain:
.
z=
h i j
k l m
n o p
where:
h=a*d k=a*e n=a*f
i=b*d l=b*e o=b*f
j=c*d m=c*e p=c*f
Thanks!

採用された回答

Jan
Jan 2013 年 9 月 16 日
編集済み: Jan 2013 年 9 月 16 日
x = [1, 2, 3]
y = [10, 20, 30]
z = x' * y
The matrix multiplication of a column vector with a row vector replies the dyadic product. x*y' would reply the dot-product.
Slower alternative:
z = bsxfun(@times, x', y)
  6 件のコメント
Sean de Wolski
Sean de Wolski 2013 年 9 月 17 日
Of course you could also put this inside of a MATLAB function block.
Jan
Jan 2013 年 9 月 17 日
Dan p wrote:
I also tried to use the blocks from the "User-defined functions" but I did not succeed.
Please show us, what you have tried and explain "did not succeed" with details.

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

その他の回答 (1 件)

Simon
Simon 2013 年 9 月 16 日
編集済み: Simon 2013 年 9 月 16 日
Hi!
x = [1, 2, 3]; % row vector
y = [2; 3; 4]; % column vector
z = y * x;

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by