Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [ yValues_regress ] = calc_y_between_points( control_Pnts, x )
- %UNTITLED Summary of this function goes here
- % Detailed explanation goes here
- yValues_regress = zeros(1, numel(x));
- for i=1:numel(x)
- for j=1:size(control_Pnts, 2) - 1
- if control_Pnts(1, j) <= x(i) && control_Pnts(1, j+1) >= x(i)
- p1x = control_Pnts(1, j);
- p2x = control_Pnts(1, j+1);
- p1y = control_Pnts(2, j);
- p2y = control_Pnts(2, j+1);
- break;
- end
- end
- if p1x > x(i) || p2x <x(i)
- warning('Warning: p1x = %d, p2x = %d, x(1, i) = %d\n', p1x, p2x, x(i));
- end
- yValues_regress(i) = ((p2y-p1y)/(p2x-p1x)*x(i)+(2*p1y*p2x-p2x*p1y-p1x*p2y)/(p2x-p1x));
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement