本文共 589 字,大约阅读时间需要 1 分钟。
在一些场景中,不同的参数下绘制出的fig是不同的,为了清晰的看到不同参数下fig的变化。可以将一组fig保存成动态图,从而就可清晰的看出参数变化对fig的影响。
在matlab中可以用imwrite()
函数实现这一个功能
利用randn(1, n)
产生正态分布的随机数,可以预期:当n越大时,生成的随机数越符合正态分布曲线。
h = figure();ax = axes(h);pic_num = 1;for i = 0:100:10000 data = randn(1,i); histogram(ax, data); title(['rand=', num2str(i)]); F=getframe(gcf); I=frame2im(F); [I,map]=rgb2ind(I,256); if pic_num == 1 imwrite(I,map,'test2.gif','gif', 'Loopcount',inf,'DelayTime',1); else imwrite(I,map,'test2.gif','gif','WriteMode','append','DelayTime',1); end pic_num = pic_num + 1; end
转载地址:http://xthd.baihongyu.com/