[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index

Re: multiplication syntax

If <.*> does not work for this large composition, then you can always break
down the column vector into just one element at a time and multiply it with
the corresponding row of the matrix. A <for> loop would do, but of course if
the <.*> syntax works, then *do* use it because it will be far faster.
Alternatively you can expand the column vector, A, using repmat(A,1,51) and
then multiply it with the matrix which now has the exact same dimensions.

Roy



"Karen Lipkow" <kl_2807@cam.ac.uk> wrote in message
news:kl_2807-82312A.17044126022004@pegasus.csx.cam.ac.uk...
>
> HI,
>
> This is a very basic question, for some reason I can't get it to work.
>
> A is a 51-by-50 matrix
> B is a 1-by-50 vector
>
> I want to multiply each of the 51 rows of A column-for-column with B, so
> that C=A(*)B is again a 51-by-50 matrix.
>
> What's the exact syntax ?
>
> I've tried all sorts of combinations of for-loops, transpose, *, .* etc,
> but must have missed the correct one, I either get an error or a 1x50
> vector.
>
>
>
> e.g., if
>
> A= [1 4 9;     B=[4;    C=[4 16 36;
>    2 8 12;        5;       10 40 60;
>    3 10 20]       6]       18 60 120]
>
> (Cij = Aij x Bj)
>
>
>
> Thank you very much for your help !
>
> Karen
> -- 
> remove underscore and seven from my email address


[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index