circlegen.m
来自「有趣的可视的数值方法 出自网站http://www.mathworks.com」· M 代码 · 共 34 行
M
34 行
function circlegen(h)%CIRCLEGEN Generate approximate circles.% CIRCLEGEN(h) uses step size h.% CIRCLE with no arguments uses h = 0.20906.if nargin < 1 h = sqrt(2*(1-cos(2*pi/30)));endshgclfset(gcf,'doublebuffer','on')z = exp(2*pi*i*(0:256)/256);grey = [.8 .8 .8];p = plot(real(z),imag(z),'-',0,0,'o',1,0,'.');set(p(1:2),'color',grey);p = p(3);set(p,'color','black','erasemode','none')axis([-2 2 -2 2])axis squaretitle(['h = ' num2str(h)])stop = uicontrol('style','toggle','string','stop');x = 1;y = 0;while ~get(stop,'value') x = x + h*y; y = y - h*x; set(p,'xdata',x,'ydata',y); drawnowendset(stop,'string','close','value',0,'callback','close')
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?