What code to automatically put the cubic splines in a plot?

3 views (last 30 days)
Say you have:
x = -10:2:10 y = sin(x)
plot(x,y,'o')
Instead of having to click the Figure Tools then clicking the cubic splines,
is there a code that will automatically activate that?
Also, how would you fill with a colour the area between the splines and the x-axis?
Cheers

Answers (1)

Paul Premakumar
Paul Premakumar on 27 Mar 2013
Why not use the SPLINE command
plot(x,y)
figure
xx = -10:.25:10;
yy = spline(x,y,xx);
%plot(xx,yy); % display your data
% Use area to fill the are under the curve
area(xx,yy);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!