Call Matlab distance metrics with function

1 view (last 30 days)
Tom
Tom on 5 Aug 2013
Hi,
I'm writing a function in which I call the built in Matlab function 'pdist'. Can I somehow have the user specify which distance to use in my function?
Something like the following:
function out = my_function(input_1, input_2, 'euclidian')
...
out = pdist(X, 'euclidian')

Answers (1)

Jan
Jan on 5 Aug 2013
Edited: Jan on 6 Aug 2013
function out = my_function(input_1, input_2, typeOfNorm)
...
out = pdist(X, typeOfNorm);
Now call your function like:
out = my_function(data1, data2, 'euclidian')

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!