# How can I get plot with smooth lines from this data?

1 view (last 30 days)
Muhammad Taseer Islam on 26 Jun 2019
Hi.
I want to get plot with smoother lines from this data.
a=(500,1000,1700,1300,1400,3900,3400,3000,2200,2400,3300,3800,4500,4500,4400,4300,4600,3700)
x=(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18)
Thanks.

Star Strider on 26 Jun 2019
If you do not have the Curve Fitting Toolbox, use the core MATLAB spline (link) function:
a=[500,1000,1700,1300,1400,3900,3400,3000,2200,2400,3300,3800,4500,4500,4400,4300,4600,3700];
x=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18];
xsm = linspace(min(x), max(x));
asm = spline(x, a, xsm);
figure
plot(x, a, '+r')
hold on
plot(xsm, asm, '-b')
hold off
grid
##### 2 CommentsShowHide 1 older comment
Star Strider on 26 Jun 2019
As always, my pleasure!

### More Answers (2)

KALYAN ACHARJYA on 26 Jun 2019
Edited: KALYAN ACHARJYA on 26 Jun 2019
a=[500,1000,1700,1300,1400,3900,3400,3000,2200,2400,3300,3800,4500,4500,4400,4300,4600,3700]';
x=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]';
f=fit(x,a,'smoothingspline')
plot(f);
Muhammad Taseer Islam on 27 Jun 2019
Oh sorry KALYAN ACHARJYA.
that was my mistake.
now it is working.
thank you u very much for your rapid reply.

infinity on 26 Jun 2019
Hello,
There is an option that you can refer,
a1 = smooth(a);
plot(x,a1)
There are many types of smooth function, you may read links below for more options.
##### 1 CommentShowHide None
Muhammad Taseer Islam on 26 Jun 2019
Thank You for your help.