From: Kevin on 22 Mar 2010 10:55 I need to know how to compute the matrix product of 2 matricies A(MxN) and B(PxQ) without using A*B. (N=P) A(i,j),B(k,l) and two matricies that are able to be computed by porduct. i have tried to get the soultion matrix to be C(s,t) i have tried to compute them using vector products and have coem up with this, for s=1:M for t=1:Q C(s,t)=dot(A(s,j),B(k,t)) end end it seems to work when i think about it in my head but does not in matlab, what am i doign wrong or how can this be ammended. thank you
From: Matt J on 22 Mar 2010 11:22 C(s,t)=dot(A(s,:),B(:,t))
From: Jan Simon on 22 Mar 2010 17:12 Dear Kevin! > I need to know how to compute the matrix product of 2 matricies A(MxN) and B(PxQ) without using A*B. (N=P) > i have tried to compute them using vector products and have coem up with this, > > for s=1:M > for t=1:Q > C(s,t)=dot(A(s,j),B(k,t)) > end > end > > it seems to work when i think about it in my head but does not in matlab, what am i doign wrong or how can this be ammended. If you state, that this does not work in Matlab, look at the error message and post it here. If it tells you, that k is not defined and using j as index fails, because j is the imaginary unit and not a integer valued real number, this should point to the problem. You can use the debugger to set a break point in the line "C(s,t) = ..." and type the calculation in the command line. This helps to identify problems and understand unexpected results. Kind regards, Jan
|
Pages: 1 Prev: Can't run Matlab runtime Next: Hspice toolbox for MAtlab |