From: doug kopet on 11 Aug 2010 20:04 Hi everyone, I'm a new matlab user and new to programming and would like to request some help. I have 2 matrices MM and BB: MM = [ 1 2 2 ; 5 3 6 ; 9 8 7; 8 8 4 ; 6 1 1 ; 5 0 5 ] BB = [ 31 32 44 ; 20 17 33; 19 44 22] I would like to multiply in the following manner using a looping procedure : result_part1=[1 2 2; 8 8 4] * [ 31 32 44]' result_part2 = [ 5 3 6 ; 6 1 1] * [ 20 17 33]' result_part3 = [9 8 7; 5 0 5]* [19 44 22]' Then, I would like to output them in the following manner: final_answer = [ 183 349 677; 680 170 205] cheers doug
From: ImageAnalyst on 11 Aug 2010 21:56 doug: Great, it looks like you did it. And you didn't even need to use looping (which we usually try to avoid). Now, what is your question? Does it need to be generalized to some variable number of rows and/or columns, or what?
From: doug kopet on 11 Aug 2010 22:08 My question is how can I do this procedure, i.e , skip every 2 rows in matrix MM for each of the first 3 rows sequentially and multiply each by its corresponding transposed row in BB. doug
From: doug kopet on 11 Aug 2010 22:18 Also,my actual work has large matrices that is why I implied that I would I have to use loops. thanks doug
From: ImageAnalyst on 11 Aug 2010 22:37 On Aug 11, 10:18 pm, "doug kopet" <onedo...(a)gmail.com> wrote: > Also,my actual work has large matrices that is why I implied that I would I have to use loops. > > thanks > doug ----------------------------------------------------------------------- Well you can start with this: for startingRow = 1:3 MM(startingRow:3:end, :) % Display just for info. BB(startingRow, :)' % Display just for info. % Do the multiplication result_part = MM(startingRow:3:end, :) * BB(startingRow)' end But I'm not sure how you're getting "final_answer." What's the algorithm for that? It's not simply summing the result_part's.
|
Next
|
Last
Pages: 1 2 Prev: PDF in matlab not the same as PDF in Excel Next: multi-rate xPC models |