Matlab坐标系?

时间:2012-03-03 00:55:34

标签: matlab

如何指定不同于全局坐标(x,y)的新坐标系

例如,我需要新的坐标系是我在Matlab上绘制的正弦波,有没有函数或方法在初始坐标系上绘制另一个正弦函数?

提前致谢..

1 个答案:

答案 0 :(得分: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