2012-03-03 142 views
1

如何比全球座標(X,Y)Matlab座標系?

例如不同的新的座標系分配,我需要新的座標系是一個正弦波,我畫了Matlab的,是有一個函數或方法來在最初的一個上畫另一個正弦函數?

在此先感謝..

+2

您是否在問如何在同一軸上繪製兩個函數?因爲這與新的座標系非常不同。 – prototoast 2012-03-03 00:58:40

回答

2

如果你想在一個軸上畫出多條曲線,使用hold

x = linspace(0,4*pi); 
figure; plot(x, sin(x)); 
hold on; 
plot(x, sin(2*x)); 
hold off; 

只要你的狀態hold on,以plot()所有呼叫都將在相同的畫直到你致電hold off。 如果你想有幾個軸在一幅圖,使用subplot()

x = linspace(0,4*pi); 
figure; % open new figure window 
subplot(2, 1, 1); % 2 lines of subplots, one column, use first one 
plot(x, sin(x)); 
subplot(2, 1, 2); % ... use second one 
plot(x, sin(2*x)); 

如果你想有幾個數字窗口,打開每個情節一個新的數字與figure

x = linspace(0,4*pi); 
figure; % open figure window for first plot 
plot(x, sin(x)); 
figure; % open new figure window for second plot 
plot(x, sin(2*x)); 

請注意,在上面的示例中,plot()始終使用最後創建的數字窗口。您還可以使用圖柄來任意繪製數字窗口:

x = linspace(0,4*pi); 
figure; % open figure window for first plot 
fig1 = gca; % get current axes handle 
figure; % open new figure window for second plot 
fig2 = gca; 
plot(fig2, x, sin(x)); % draw into second figure window 
plot(fig1, x, sin(2*x)); % draw into first figure window