本文介绍了如何在matlab中同一个x轴上多个图形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有for循环,绘制多个图,每个图都有自己的窗口。我想连接这些图只使用一个图形和X轴。
有人可以举个例子吗?
解决方案
在一个图表中的几个点。
x = [1,2,3, 4];
y = [5,3,4,6];
图; %创建一个新的数字窗口。
坚持;
for i = 1:length(x)
plot(x(i),y(i),'r *'); %绘制一颗红色的星星。
end
I have for loop that plots multiple graphs, whereby each graph has own window.I would like to concatenate these graphs using only one graph and x y axis.
Could someone give an example?
解决方案
The following code plots a few points in a single graph. You can place anything you'd like to plot in this plot() function.
x = [1,2,3,4];
y = [5,3,4,6];
figure; % Create a new figure window.
hold on;
for i = 1:length(x)
plot(x(i), y(i), 'r*'); % Plot a red star.
end
这篇关于如何在matlab中同一个x轴上多个图形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!