概述
您需要使用命令hold on来确保每次绘制新内容时都不会删除绘图.
function test1
figure %# create a figure
hold on %# make sure the plot isn't overwritten
x=1:0.1:10;
%# if you want to use multiple colors
nPlots = 5; %# define n here so that you need to change it only once
color = hsv(nPlots); %# define a colormap
for k=1:nPlots; %# default step size is 1
y=k*sin(x);
plot(x,y,'Color',color(k,:));
end % /for-loop
end % /test1 - not necessary, btw.
编辑
您也可以在没有循环的情况下执行此操作,并绘制2D数组,如@Ofri所示:
function test1
figure
x = 1:0.1:10;
k = 1:5;
%# create the array to plot using a bit of linear algebra
plotData = sin(x)' * k; %'# every column is one k
plot(x,plotData)
最后
以上就是等待啤酒为你收集整理的matlab迭代图程序,尝试使用MATLAB创建迭代(初学者)的全部内容,希望文章能够帮你解决matlab迭代图程序,尝试使用MATLAB创建迭代(初学者)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复