Problem 51. Find the two most distant points
Solution Stats
Problem Comments

6 Comments
More easy that it seems.
You need to specify "Euclidean" distance :)
Good problem, not too hard but required thinking
Please add the next test :
p = [0,0;
2,1;
2,6;
1,6];
ix_correct = [1 3];
assert(isequal(mostDistant(p),ix_correct))
The solutions of the form:
[~,indx]=max(dist(p'));
unique(indx)
will fail, the last line will return an extra index [1,3,4] instead of just [1,3]
refer to
Convex Hull therom and the Graham's Scan method
+1
Solution Comments

1 Comment
hehe, just trying to see if they have any hidden tests for the code.

2 Comments
Since yesterday, I submit the solution ,and it always shows "
While evaluating the solution, the server encountered an error caused by temporary unavailability of MATLAB Service. Wait a few minutes for the MATLAB Service to return, and then rescore."
I don't know how to deal with it?
You should be able to submit solutions now. Sorry for the inconveniene.

2 Comments
no function squareform either... pffff
Cody utilizes vanilla MATLAB (no toolboxes).

1 Comment
Why is there "undefined function 'dist' for input arguments of type 'double'."? Works on my machine (and online matlab too)

1 Comment
I solved the problem by an tedious approach.

1 Comment
remove ' diff ',but adds size _

1 Comment
:)))))

1 Comment
I am using matlab2010 but dist function is not available in it. Can you tell me how and where can I use this?

2 Comments
Without dist, but with str2num
I think it works w/ just x*[1;i] . No need to convert from a string.

1 Comment
i'm not sure this can always get the right answer,
so i need more debugging.

2 Comments
what is 'i'? This is strange but works.
@Claudia, "i" is the imaginary number sqrt(1). Unless you overwrite it, it's always available to you in MATLAB without needing to declare it.

1 Comment
Excuse me?
This solution works fine, but requires the stats toolbox to function!

4 Comments
I dont get whay sort(unique(ix)) will give you the location of the two points. it is wrong for these points (0.9631 0.5468),(0.5211 0.2316),(0.4889,0.6241),(0.6791 0.3955),(0.3670 0.9890),
sort(unique(ix)) will return [1 2 5].
I think this solution is not right
I agree.
there may be something out of word,
if i put:
p =[1 0; 0 1;0 0; 1/sqrt(2) 1/sqrt(2) ]
your command would not right,
but 'unique' is very admirable.

1 Comment
This is the smallest solution not to use "dist," which is not in core Matlab. Nicely done!

1 Comment
I don't know why Cody allows answers which depend on toolboxes. The whole point should be to write one's own "distance" function.

1 Comment
Hard to believe you let 'dist' in but not 'pdist'.

1 Comment
pdist is not allowed!

1 Comment
I find this a little bit unfair: dist is a neural network toolbox function. It is not available in MATLAB core, and the problem does not specify this toolbox is needed.

1 Comment
Shame on me...
Problem Recent Solvers2346
Suggested Problems

287 Solvers

Back to basics 11  Max Integer
755 Solvers

287 Solvers

421 Solvers

807 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!