A1: refer to http://blog.csdn.net/seamanj/article/details/50898781
A2: refer to http://blog.csdn.net/seamanj/article/details/50899295
x1 = linspace(0,1,100); y11 = 1 - x1; y12 = x1; x2 = linspace(1,2,100); y21 = 2-x2; y22 = x2-1; x3 = linspace(2,3,100); y31 = 3-x3; y32 = x3-2; x4 = linspace(3,4,100); y41 = 4-x4; y42 = x4-3; hold on plot(x1,y11,'.c') plot(x1,y12,'.y') plot(x2,y21,'.y') plot(x2,y22,'.r') plot(x3,y31,'.r') plot(x3,y32,'.g') plot(x4,y41,'.g') plot(x4,y42,'.m') x = [x1 x2 x3 x4]; y_real = [0.3+0.2*x1 0.6-0.1*x2 0.2*x3 1.8-0.4*x4]; y = [0.3*y11+0.5*y12 0.5*y21+0.4*y22 0.4*y31+0.6*y32 0.6*y41+0.2*y42]; plot(x,y_real,'.k') plot(x,y,'-b')