2013-04-30 106 views
0

比方說,我有兩個矩陣的x和y繪製使用一個矩陣幾行

X = [1 2 3 1 2] Y = [1 2 3 1 3]

我要繪製2來自它的線,前三點,然後是最後兩點。

最後我想得到這個陰謀。我可以用Matlab做到嗎?

enter image description here

回答

1

使用​​索引爲plot指定座標對向量輸入參數的:

plot(x(1:3), y(1:3), x(4:5), y(4:5)) 
1

使用hold all繪製在同一軸線上的幾行。

figure 
plot(x(1:3), y(1:3)); 
hold all; 
plot(x(4:end), y(4:end)); 
1

試試這個

plot(x(1:3),y(1:3),'b',x(4:end),y(4:end),'r')