Plotting a smooth curve from points

조회 수: 36 (최근 30일)
Muhammadhn Muhammadh Khalid
Muhammadhn Muhammadh Khalid 2020년 3월 3일
댓글: Rajendra Gupta 2021년 11월 13일
Hi there, I' m trying the same thing with the attached data set. But ending up in a more curvy plot. I need a smooth plot similar, but better than the attached figure. I tried the polyval funtion as shown here https://au.mathworks.com/matlabcentral/answers/500026-plotting-a-smooth-curve#answer_409817, but thats creating a more curvy plot. any help would be highly appreciated. Thanks
  댓글 수: 1
Rajendra Gupta
Rajendra Gupta 2021년 11월 13일
Try replacing 'spline with other options, such as 'cubic', also called 'pchip'. It resolved my problem.

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

답변 (1개)

Marshall Dunlap
Marshall Dunlap 2020년 3월 4일
With your values in MATLAB create a more well-defined vector of x values (xi). Use the interp1 function to implement a cubic spline interpolation. Then plot the orginial points and then the cubic spline interpolation.
x = [your values];
v = [your values];
xi = [x(1):0.0000001:x(end)];
vid=interp1(x,v,xi,'spline');
plot(x,v,'b*')
hold on
plot(xi,vid,'r')
  댓글 수: 1
Rajendra Gupta
Rajendra Gupta 2021년 11월 12일
This is the simplest smoothing code. Just two additional lines and you have a smooth plot. Good work.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by