Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. function [ yValues_regress ] = calc_y_between_points( control_Pnts, x )
  2. %UNTITLED Summary of this function goes here
  3. % Detailed explanation goes here
  4. yValues_regress = zeros(1, numel(x));
  5. for i=1:numel(x)
  6. for j=1:size(control_Pnts, 2) - 1
  7. if control_Pnts(1, j) <= x(i) && control_Pnts(1, j+1) >= x(i)
  8. p1x = control_Pnts(1, j);
  9. p2x = control_Pnts(1, j+1);
  10.  
  11. p1y = control_Pnts(2, j);
  12. p2y = control_Pnts(2, j+1);
  13. break;
  14. end
  15. end
  16.  
  17. if p1x > x(i) || p2x <x(i)
  18. warning('Warning: p1x = %d, p2x = %d, x(1, i) = %d\n', p1x, p2x, x(i));
  19. end
  20.  
  21. yValues_regress(i) = ((p2y-p1y)/(p2x-p1x)*x(i)+(2*p1y*p2x-p2x*p1y-p1x*p2y)/(p2x-p1x));
  22. end
  23.  
  24.  
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement