MATLAB: How to plot with 3 matrix

plot

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')

Best Answer

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')
.