Cody

Solution 466015

Submitted on 3 Jul 2014 by Jon
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
%% cd=randi(100); gd=-randi(100); linef=(cd-gd)*rand(randi([50,100]),2)+gd; % n=size(linef,1); ldist=zeros(n); for a=1:n for b=1:n if linef(a,1)>0&&linef(b,2)>0 ldist(b,a)=(linef(a,1)+linef(b,2)-cd).^2; elseif linef(a,1)<0&&linef(b,2)<0 ldist(b,a)=(linef(a,1)+linef(b,2)-gd).^2; else ldist(b,a)=(abs(linef(a,1)-linef(b,2))-(cd-gd)).^2; end end end y_correct=ldist; f_result=measure_dist(linef,cd,gd); assert(all(abs(f_result(:)-y_correct(:))<0.1))