フィルターのクリア

Can you help me solving that?

1 回表示 (過去 30 日間)
Rengin
Rengin 2014 年 1 月 30 日
編集済み: Walter Roberson 2014 年 1 月 30 日
A=[1 2 3 4 5 6 7 8 9 10]
B=[a b c d e f ]
I want to create such a matrix as a result:
C[1+a 1+b 1+c 1+d 1+e 1+f ; 2+a ... 2+f ; 3+a... 3+f; ......;10+a...10+f]
A is 1x10 and B is 1x6 sized matrices. C is 10x6 sized matrix.
Thank you for your help!
  1 件のコメント
Image Analyst
Image Analyst 2014 年 1 月 30 日
Is this homework?

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

採用された回答

Mischa Kim
Mischa Kim 2014 年 1 月 30 日
How about:
A = [1 2 3 4 5 6];
b = [1 2 3];
C = zeros(size(A'*b));
for ii = 1:length(A)
C(ii,:) = b + A(ii);
end
  1 件のコメント
Rengin
Rengin 2014 年 1 月 30 日
Thank you so much :)

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

その他の回答 (2 件)

Iain
Iain 2014 年 1 月 30 日
編集済み: Iain 2014 年 1 月 30 日
C = A * B'; % will give you a 1x1.
C = (A' * B)'; will give you a 10x6.
C = A'*B; will give you a 6 x 10.
  2 件のコメント
Rengin
Rengin 2014 年 1 月 30 日
Yes you are right but the thing is that I am getting the first element of A matrix (which is "1" ) and adding it the first row of the B matrix and getting the first row of C matrix (1+a 1+b 1+c 1+d 1+e 1+f). I am doing that procedure untill fulfill all of my rows (I have 6 rows)... I know how to multiply the matrices. My guestion is how to create a new matrix according to my specific summary rule.
Jos (10584)
Jos (10584) 2014 年 1 月 30 日
you mean: I have 10 rows ...

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


Jos (10584)
Jos (10584) 2014 年 1 月 30 日
No need for an explicit loop as you can exploit the power of MatLab with BSXFUN.
% example data
A =[1 2 3 4 5 6 7 8 9 10]
B =[100 200 300 400 500]
% engine
C = bsxfun(@plus, A(:), B)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by