MATLAB: Expansion on the Devision of matrix by matrix Q

matrix array

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

Best Answer

  • 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]))