smooth line in plot
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dion Theunissen
le 2 Juin 2021
Commenté : Star Strider
le 2 Juin 2021
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 commentaires
Réponse acceptée
Star Strider
le 2 Juin 2021
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 commentaires
Star Strider
le 2 Juin 2021
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')
.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!