Plot curve through data points
조회 수: 44 (최근 30일)
이전 댓글 표시
Hi,
I am trying to plot a curve line through a set of points as showin in my drawing 

I am using the following code to interpolate, but it is giving me the wrong graph.
x = [15.9, 16.9, 17.5, 19.6];
v = [1.108287307, 1.130052358, 1.118465615, 1.102750628];
xi = [x(1):0.0000001:x(end)];
vid=interp1(x,v,xi,'spline');
plot(x,v,'b*')
hold on
plot(xi,vid,'r')
Any help would be appreciated,
Thanks.
댓글 수: 0
채택된 답변
the cyclist
2023년 1월 14일
x = [15.9, 16.9, 17.5, 19.6];
v = [1.108287307, 1.130052358, 1.118465615, 1.102750628];
xi = [x(1):0.0000001:x(end)];
vid=interp1(x,v,xi,'pchip');
figure
plot(x,v,'b*')
hold on
plot(xi,vid,'r')
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!