| MATLAB Central > MATLAB Newsreader > Help needed - Adding up combinations of element... |
|
|
|
Subject: Help needed - Adding up combinations of elements in a matrix. From: Drew Date: 16 Nov, 2009 21:27:02 Message: 1 of 7 |
|
I have a sample matrix. |
|
Subject: Help needed - Adding up combinations of elements in a matrix. From: Drew Date: 16 Nov, 2009 21:33:03 Message: 2 of 7 |
|
I really would just like to see an example of how you could accomplish adding up the different combination of elements (one from each row) in a matrix using a loop. |
|
Subject: Help needed - Adding up combinations of elements in a matrix. From: someone Date: 16 Nov, 2009 22:00:03 Message: 3 of 7 |
|
"Drew " <drewtoid@gmail.com> wrote in message <hdsg36$5ve$1@fred.mathworks.com>... |
|
Subject: Help needed - Adding up combinations of elements in a matrix. From: Doug Date: 16 Nov, 2009 23:27:01 Message: 4 of 7 |
|
q=[1 2 3;3 2 1; 4 4 4]; |
|
Subject: Help needed - Adding up combinations of elements in a matrix. From: Matt Fig Date: 17 Nov, 2009 00:00:20 Message: 5 of 7 |
|
Unless I misunderstand, I think the OP is talking more like this (a rough draft that gets the job done, no optimizations added): |
|
Subject: Help needed - Adding up combinations of elements in a matrix. From: Drew Date: 17 Nov, 2009 00:07:01 Message: 6 of 7 |
|
Thank for you the responses so far. I can elaborate, sorry it was originally unclear. |
|
Subject: Help needed - Adding up combinations of elements in a matrix. From: Matt Fig Date: 17 Nov, 2009 00:24:04 Message: 7 of 7 |
|
So modify the solution I gave above to get rid of F and the outer loop. |
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
Contact us at files@mathworks.com
