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

조회 수: 1 (최근 30일)
Muhammad Taseer Islam
Muhammad Taseer Islam 2019년 6월 26일
댓글: Muhammad Taseer Islam 2019년 6월 27일
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
Star Strider 2019년 6월 26일
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
How can I get plot with smooth lines from this data - 2019 06 26.png

추가 답변 (2개)

KALYAN ACHARJYA
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
  댓글 수: 5
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 6월 27일
Have you have run the code, as provided (Copy and run)?
Can you show me the error?
Muhammad Taseer Islam
Muhammad Taseer Islam 2019년 6월 27일
Oh sorry KALYAN ACHARJYA.
that was my mistake.
now it is working.
thank you u very much for your rapid reply.

댓글을 달려면 로그인하십시오.


infinity
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.

카테고리

Help CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by