![How can I get plot with smooth lines from this data - 2019 06 26.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/226417/How%20can%20I%20get%20plot%20with%20smooth%20lines%20from%20this%20data%20-%202019%2006%2026.png)
How can I get plot with smooth lines from this data?
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Star Strider
2019-6-26
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
![How can I get plot with smooth lines from this data - 2019 06 26.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/226417/How%20can%20I%20get%20plot%20with%20smooth%20lines%20from%20this%20data%20-%202019%2006%2026.png)
更多回答(2 个)
KALYAN ACHARJYA
2019-6-26
编辑:KALYAN ACHARJYA
2019-6-26
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);
![kalyan_11.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/226413/kalyan_11.png)
5 个评论
KALYAN ACHARJYA
2019-6-27
Have you have run the code, as provided (Copy and run)?
Can you show me the error?
infinity
2019-6-26
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!