Prev: Selecting 3d coordinates....kinda like a '3d' ginput
Next: RQ decomposition with positive diagonal entries
From: ravi on 19 Feb 2010 21:46 I have 2 matrices. A = 658 96 1 760 292 1 777 353 1 B = 1072 103 1 1089 298 1 1034 357 1 Using the cross function how can I cross multiple each row one at a time? I know I have to use a for loop. I've been trying but just dont know how. Can anyone help. Best ravi
From: Matthew on 19 Feb 2010 22:35 You don't need a loop. Just use the third argument in cross, i.e. cross(A,B,1) "ravi " <ravi_071(a)hotmail.com> wrote in message <hlnidb$9u1$1(a)fred.mathworks.com>... > I have 2 matrices. > > A = > > 658 96 1 > 760 292 1 > 777 353 1 > > B = > > 1072 103 1 > 1089 298 1 > 1034 357 1 > > Using the cross function how can I cross multiple each row one at a time? I know I have to use a for loop. I've been trying but just dont know how. > > Can anyone help. > Best > ravi
From: ravi on 19 Feb 2010 23:00 I don't think that will work matthew. I tried it ,i.e. cross(A,B,1) and got the same result. i am looking to cross multiply each row of A by each row of B. So for example. cross(A(1,:), B(1,:)) will give me : >> cross(A(1,:), B(1,:)) ans = -7 414 -35138 I now want to do this for all the following rows of A and B. That's why I thought a for loop was needed. Any other suggestion? Thanks ravi
From: ravi on 19 Feb 2010 23:04 I don't think that will work matthew. I tried it ,i.e. cross(A,B,1) and got the same result. i am looking to cross multiply each row of A by each row of B. So for example. cross(A(1,:), B(1,:)) will give me : >> cross(A(1,:), B(1,:)) ans = -7 414 -35138 I now want to do this for all the following rows of A and B. That's why I thought a for loop was needed. Any other suggestion? Thanks ravi
From: Wayne King on 19 Feb 2010 23:31 "ravi " <ravi_071(a)hotmail.com> wrote in message <hlnmvj$ghf$1(a)fred.mathworks.com>... > I don't think that will work matthew. > > I tried it ,i.e. cross(A,B,1) and got the same result. > > i am looking to cross multiply each row of A by each row of B. > > So for example. > > cross(A(1,:), B(1,:)) will give me : > > >> cross(A(1,:), B(1,:)) > > ans = > > -7 414 -35138 > > > I now want to do this for all the following rows of A and B. That's why I thought a for loop was needed. > > Any other suggestion? > > Thanks > ravi Hi Ravi, For the way you have your matrices, cross(A',B') the columns of the answer are the cross products of the rows of A and B. Hope that helps, Wayne
|
Next
|
Last
Pages: 1 2 Prev: Selecting 3d coordinates....kinda like a '3d' ginput Next: RQ decomposition with positive diagonal entries |