Advertisement
lossyy

Scilab5_1

Mar 13th, 2021 (edited)
3,087
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 0.55 KB | None | 0 0
  1. clc
  2. vX = [-0.3 0.1 0.5 0.9 1.3 1.7 2.1];
  3. vY = [-1.3 2.2 3.5 5.8 7.2 6.0 5.8];
  4. X=1.43;
  5. vTemp=[0 0 0 0 0 0 0]
  6. j=1;
  7. i=1;
  8. n=7;
  9. Px=0;
  10. xi=vX(1);
  11. xii=vX(1);
  12. x0=vX(1);
  13. y0=vX(1);
  14. Ptmp=1;
  15.  
  16. for i = 1:n;
  17. yi=vY(i);
  18. xii=vX(i);
  19.  
  20. for j = 1:n;
  21. xi=vX(j);
  22. if (xii<>xi) then
  23. Ptmp=Ptmp*((X-xi)/(xii-xi));
  24. end
  25. end
  26.  
  27. Px=Px+Ptmp*yi
  28. vTemp(i)=Px;
  29. Ptmp=1;
  30. end
  31. Px
  32. vTemp
  33.  
  34. plot2d(vX, vTemp, style=[color("magenta")], leg="Лагранж");
  35. d=splin(vX,vTemp);
  36. S=interp(-0.3:0.01:2.1, vX,vTemp,d);
  37. plot2d(vX',vTemp',-1);
  38. plot2d((-0.3:0.01:2.1)',S',9,'000')
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement