simple, linear and cubic calculation for plot

matlab code for spline and cubic plot

Vous suivez désormais cette soumission

For the given x-y data points in table below, use linear, spline and cubic interpolation methods to calculate the value of y. Plot data points and graphs of three interpolation methods on the same figure. Find the value of y for x=7 using three interpolation methods.
x=1:5;
y=[0.8530 0.6221 0.3510 0.5132 0.4018];
x2=1:0.01:10;
ylin=interp1(x,y,x2,'linear');
yspl=interp1(x,y,x2,'spline');
ycub=interp1(x,y,x2,'cubic');
plot(x2,ylin,'r',x2,yspl,'k',x2,ycub,'s');
fprintf('at x=7 value:\n');
fprintf('linear: %f\n spline: %f\n cubic: %f',ylin(7),yspl(7),ycub(7));

Citation pour cette source

Arthur Matlabus (2026). simple, linear and cubic calculation for plot (https://fr.mathworks.com/matlabcentral/fileexchange/167331-simple-linear-and-cubic-calculation-for-plot), MATLAB Central File Exchange. Extrait(e) le .

Add the first tag.

Informations générales

Compatibilité avec les versions de MATLAB

  • Compatible avec toutes les versions

Plateformes compatibles

  • Windows
  • macOS
  • Linux
Version Publié le Notes de version Action
1.1.0

change

1.0.0