File Exchange

## Minkowski Sum

version 1.1 (1.65 KB) by

Minkowski sum of two arrays

2.33333
3 Ratings

Updated

S=MINKSUM(A,B) produces the Minkowski sum of two sets A and B in Euclidean space, the result being the addition of every element of A to every element of B.

[S,D]=MINKSUM(A,B) returns the Minkowski sum S, and also the multiplicity of each element in S.

The number of columns represent the dimensionality. An array of M points in N-D space is an MxN array. A vector of 1D values is a column vector.

If the sizes of A and B are MAxN and MBxN respectively, then the size of S will be at most (MA*MB)xN

Example:
A=[1 1; 2 1; 2 2; 1 2]; B=[3 3; 4 3; 4 4; 3 4];
[S,D]=minksum(A,B);
plot(A(:,1),A(:,2),'*',B(:,1),B(:,2),'s',S(:,1),S(:,2),'d')
axis([0 7 0 7])

Anatoly Nemirko

Alessio Maffei

Mehdi Nazarbeigi

### Mehdi Nazarbeigi (view profile)

I follow the instruction exactly but I received an error which states that the minksum function is undefined, whats the problem?

Samuel Cole

### Samuel Cole (view profile)

Alex,

minksum([1;2],[6;7])

ans =

7
8
9

Alex Dytso

### Alex Dytso (view profile)

I don't think that your code works.
Try this:

X2=[1 2]
X2 = 1 2
>> X1=[ 6 7]
X1 = 6 7
>> minksum(X1,X2)
ans =7 9

the answer should be 7 8 9