我是靠谱客的博主 等待啤酒,这篇文章主要介绍matlab迭代图程序,尝试使用MATLAB创建迭代(初学者),现在分享给大家,希望可以做个参考。

您需要使用命令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迭代图程序内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部