On Tue, Mar 7, 2017 at 4:24 AM, Thomas D. Dean <address@hidden
<mailto:address@hidden>> wrote:
On 03/06/2017 07:06 PM, Thomas D. Dean wrote:
I have an application that is called with two points and returns the
distance between the points and a mid point. One example returns a
distance of 5474. My function is not linear. But, a more simple
example illustrates my problem.
Here is a better example, which produces the output I want to save.
The printf(...) statement displays the data I want to keep, in the
order I want it.
Do you really want to recurse?
function [dist, mid] = gcr(p1,p2)
p3 = p2 - p1;
dist = sqrt(p3*p3');
mid = (p1 + p2) ./ 2;
endfunction;
list = [1000,2000; 8000,9000];
idx = 1;
while idx < size(list,1)
[distance, midpoint] = gcr(list(idx, :), list(idx+1, :));
if distance > 300
list = [list(1:idx, :); midpoint; list((idx+1):end, :)];
else
idx++;
end
end