This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.
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))
|
298 Solvers
Project Euler: Problem 1, Multiples of 3 and 5
1063 Solvers
247 Solvers
Calculate the derivative of a polynomial
139 Solvers
201 Solvers