Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: matrix: multiply each element by each combination of all other element
Date: Mon, 6 Jun 2011 14:32:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 14
Message-ID: <isiod2$dmo$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1307370722 14040 172.30.248.35 (6 Jun 2011 14:32:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 6 Jun 2011 14:32:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2904606
Xref: news.mathworks.com comp.soft-sys.matlab:730453

This should be a simple problem but I haven't been able to figure out an efficient way to do it. If I have a matrix, or vector, and I want to multiply each element by every other element, and every combination of multiples of every other element, what is the best way to do it?

for ex: [1 2 3 4 5] would go to 

[1, 2, 3, 4, 5, 2*3, 2*4, 2*5, 2*3*4, 2*4*5, 3*4*5, 4*5, 3*5, 3*4, 2*3*4*5]

Also, is there a simple way to test for and eliminate identical elements? 
For example, [ 1 2 3 3 3 4 5] could go to [1 2 3 4 5] or [1 2 3 0 0 4 5].

I've tried messing around with multi-dimensional arrays, and thought of crazy for loops, but those seem unneccesarily complicated for what should be a simple problem. 

Answering this^ would be helpful - the real problem i'm trying to do though, is to find all  the divisors of a given number. Using factor(x) obviously gives all the prime factors. 

Thanks