smooth line in plot
2 次查看(过去 30 天)
显示 更早的评论
hi,
I have a plot which contains 6 points. Now i want to smooth the line. How can I do that?
a = 0 1.56809885737654 1.00861433623079
1 0.477810012662993 0.172723989683935
2 0.307057557611696 0.0369907704137005
3 0.301187535069457 0.0712463310209048
4 0.250962057090148 0.0847637163609592
5 0.208201848906565 0.0233647321748921
0 个评论
采纳的回答
Star Strider
2021-6-2
a = [0 1.56809885737654 1.00861433623079
1 0.477810012662993 0.172723989683935
2 0.307057557611696 0.0369907704137005
3 0.301187535069457 0.0712463310209048
4 0.250962057090148 0.0847637163609592
5 0.208201848906565 0.0233647321748921];
ai = linspace(min(a(:,1)),max(a(:,1)));
a1 = interp1(a(:,1), a(:,2:end), ai, 'pchip');
figure
plot3(a(:,1), a(:,2), a(:,3), 'p')
hold on
plot3(ai, a1(:,1), a1(:,2), '-r')
hold off
grid on
figure
plot(a(:,2), a(:,3), 'p')
hold on
plot(a1(:,1), a1(:,2), '-r')
hold off
grid
axis('equal')
ai = linspace(max(a(:,2)),min(a(:,2)));
a2 = interp1(a(:,2), a(:,3), ai, 'makima');
figure
plot(a(:,2), a(:,3), 'p')
hold on
plot(ai, a2, '-r')
hold off
grid
axis('equal')
.
2 个评论
Star Strider
2021-6-2
In that instance, just use the first part of my Answer, that being (with a few tweaks) —
a = [0 1.56809885737654 1.00861433623079
1 0.477810012662993 0.172723989683935
2 0.307057557611696 0.0369907704137005
3 0.301187535069457 0.0712463310209048
4 0.250962057090148 0.0847637163609592
5 0.208201848906565 0.0233647321748921];
ai = linspace(min(a(:,1)),max(a(:,1)));
a1 = interp1(a(:,1), a(:,2:end), ai, 'makima');
figure
plot3(a(:,1), a(:,2), a(:,3), 'p')
hold on
plot3(ai, a1(:,1), a1(:,2), '-r')
hold off
grid on
xlabel('X')
ylabel('Y')
zlabel('Z')
axis('equal')
.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!