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))
|
2933 Solvers
Arrange Vector in descending order
1793 Solvers
68 Solvers
07 - Common functions and indexing 6
281 Solvers
poll: would you like the regexp (?@cmd) functionality to be banned in Cody?
147 Solvers