Home I want to plot line with 3 colors on MATLAB

# I want to plot line with 3 colors on MATLAB

user4679
1#
user4679 Published in September 21, 2018, 2:52 am

I have 3 variables, x, y, z. I want to plot line with 3 colors, red at h=0, green at h=1, blue at h=2.

x = [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14];
y = [0 1 2 1 3 4 7 9 8 6 5 3 2 1 0];
h = [0 0 0 0 0 1 1 1 1 1 2 2 2 2 2];
color = [1 0 0 ; 0 1 0 ; 0 0 1];

• Duplicate of Multiple colors in the same line – Wolfie Dec 7 '17 at 18:14