Advertisement
Guest User

test1

a guest
Apr 22nd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. function ans=lagranges(xxx,yyy,xx)
  2. coeficients=zeros(array(xxx),array(xxx));
  3. for i=1:array(xxx)
  4. poly=1;
  5. denominator=1;
  6. for j=1:array(xxx)
  7. if j~=i
  8. poly=conv(poly,[1 -xxx(j)]);
  9. denominator=denominator*(xxx(i)-xxx(j));
  10. end
  11. end
  12. coeficients(i,:)=poly/denominator;
  13. end
  14. if integrand==1
  15. ans=coeficients;
  16. elseif integrand==2
  17. ans=yyy*coeficients;
  18. else
  19. ans=polyval(yyy*coeficients,xx);
  20. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement