Expansion on my Devision of matrix by matrix Q?

조회 수: 1 (최근 30일)
Scragmore
Scragmore 2011년 10월 21일
Can I expand on this,
x = [4; 8; 12; 16; 20];
y = [2 4];
Qa = bsxfun(@rdivide,x,y);
Returns Qa = [2 1; 4 2; 6 3; 8 4; 10 5]
Now if I
Qb = Qa*y;
I don't get four columns but an error. Is there a way to step through each column of 'Qa' and multiply by each entry in 'y'.
Additional Q?
I am slowly building up a function with the above math. I have tried creating an output matrix were the series are in a different order.
Function_Matrix_out = [Qa.series1, x, Qa.series2];
again I return and error. Could you explain where I am going wrong.
Thanks,
AD
  댓글 수: 2
Fangjun Jiang
Fangjun Jiang 2011년 10월 21일
What do you mean? Why there should be "four columns" when your Qa is 5x2?
What do your mean Qa.series1? You mean the first column? Please use standard term.
Scragmore
Scragmore 2011년 10월 21일
Sorry don't know what the standard terms are. What I want is each column in QA, to be multiplied respectively by each figure in y, so you would get;
Qb = [4 8 2 4; 8 16 4 8; 12 24 6 12; 16 32 8 16; 20 40 10 20];

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2011년 10월 21일
Well, you will have to define the order of the columns you want in the result, but
bsxfun(@times, kron(Qa,[1 1]), kron([1 1],y))
or (different column order)
bsxfun(@times, kron([1 1],Qa), kron(y,[1 1]))
  댓글 수: 5
Andrei Bobrov
Andrei Bobrov 2011년 10월 21일
reshape(bsxfun(@times,reshape(Qa,[],1,2),y),[],4)
Scragmore
Scragmore 2011년 10월 22일
Thanks again for pointing me in the right direction. I have had a quick play and I think I only need;
kron(Qa, y);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by