How to plot with 3 matrix
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Mi Tung
il 27 Set 2020
Commentato: Star Strider
il 28 Set 2020
Hi everyone,
I used "plot" for drawing 2 two curve in one plot. I got it but one from these (red line) is not beautiful (the curve is not smooth) and I didn't understand why in area legend's didn't show green line. Anyone help me please. Below show the code I did. Thank you for advance.
clear all;
clc;
hold on
kr=[0 10 20 30 40 50 60 70 80 90];
M1=[0 0.2757 0.4979 0.4989 0.4481 0.3644 0.2910 0.2228 0.1380 0.0346];
M2=[0 0.0241 0.0916 0.1786 0.2613 0.3322 0.3895 0.4343 0.4658 0.4809];
plot(kr,M1,'x',0:90, interp1(kr,M1,[0:90],'spline'),'r','linewidth',1.5);
plot(kr,M2,'x',0:90, interp1(kr,M2,[0:90],'spline'),'g','linewidth',1.5);
grid on
xlabel('heel angel')
ylabel('arm')
legend('ld','ls','Location','northwest')
title('Diagram stability')
0 Commenti
Risposta accettata
Star Strider
il 27 Set 2020
If you want the red and green lines to show, you need to plot them separately, and create handles for them to pass to the legend call:
hold on
kr=[0 10 20 30 40 50 60 70 80 90];
M1=[0 0.2757 0.4979 0.4989 0.4481 0.3644 0.2910 0.2228 0.1380 0.0346];
M2=[0 0.0241 0.0916 0.1786 0.2613 0.3322 0.3895 0.4343 0.4658 0.4809];
plot(kr,M1,'x')
hp1 = plot(0:90, interp1(kr,M1,[0:90],'spline'),'r','linewidth',1.5);
plot(kr,M2,'x')
hp2 = plot(0:90, interp1(kr,M2,[0:90],'spline'),'g','linewidth',1.5);
grid on
xlabel('heel angel')
ylabel('arm')
legend([hp1 hp2], 'ld','ls','Location','northwest')
title('Diagram stability')
.
2 Commenti
Star Strider
il 28 Set 2020
My pleasure!
It looks very smooth to me already. I do not know what ‘more smooth’ means to you, so I defer to you to experiment with it. One option is to use 'pchip' (my usual preference) or 'makima' rather than 'spline'. The 'makima' method appears to me to work best here, however that is your decision.
If my Answer helped you solve your problem, please Accept it!
.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!