Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc;clear;
- % setup data
- h = 0.01;
- e = 0.001;
- x = (0:h:1);
- % normal bump
- y = exp(-(x-0.3).^2/0.05^2) + e*randn(size(x));
- % very wild stuff
- % y = sin(40*x);
- plot(x,y)
- p = randperm(numel(x));
- x = x(p);
- y = y(p);
- plot(x,y,'-b',x,y,'or');
- % check:
- x = x-min(x); x=x/max(x);
- y = y-min(y); y=y/max(y);
- [~,ix] = sort(x);
- [~,iy] = sort(y);
- d1 = sum(sqrt(diff(x(ix)).^2 + diff(y(ix)).^2));
- d2 = sum(sqrt(diff(x(iy)).^2 + diff(y(iy)).^2));
- disp('negative difference = flipped:')
- disp([d2-d1, d2, d1]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement