Advertisement
paulogp

Splines

Aug 7th, 2011
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.49 KB | None | 0 0
  1. function [p] = spline(ponto)
  2. % paulogp
  3. % utilizacao de splines
  4.  
  5.     % Obter valores da tabela
  6.     % m=csvread('spline_tabela.m');
  7.     m = importdata('spline_tabela.m', '\t');
  8.    
  9.     % linha
  10.     x = m(:,1)';
  11.     f = m(:,2)';
  12.    
  13.     % splines
  14.     p = spline(x, f, ponto);
  15.    
  16.     cs = spline(x, [0 f 0]);
  17.     xx = linspace(0, 4, 30);
  18.    
  19.     % construcao do grafico
  20.     plot(x, f, 'x', xx, ppval(cs,xx), '-');
  21. end
  22.  
  23.  
  24. % ficheiro: spline_tabela.m
  25. 0   0.0
  26. 1   1.5
  27. 2   0.5
  28. 3   0.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement