smooth line in plot
조회 수: 5 (최근 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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!