Advertisement
Guest User

Untitled

a guest
Apr 8th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.62 KB | None | 0 0
  1. function res = spline_last(a, b, n, X)
  2.     h = (b - a)/(n-1);
  3.     spline_coeffs = spline(X);
  4.     inter = a : h : b;
  5.     original_y = zeros(1, 100);
  6.     spline_y = zeros(1, 100);
  7.     z = 1;
  8.    
  9.     h = (b - a) / (100*(n-1));
  10.     line = 1;
  11.     k = 3;
  12.     curr_iter = inter(2);
  13.     for i = a : h : b
  14.         original_y(z) = func(i);
  15.         if (i > curr_iter && line < n-1)
  16.             %disp(i);
  17.             line++;
  18.             curr_iter = inter(k);
  19.             k++;
  20.         endif
  21.         spline_y(z) = polyval(spline_coeffs(line, :), i);
  22.         z++;
  23.     endfor
  24.     res = max(abs(spline_y - original_y));
  25. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement