⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 expgui.m

📁 exm for Experiments with MATLAB (by Cleve Moler in 2008), 这本书是关于MATLAB的教材
💻 M
字号:
function expgui(action)
% EXPGUI  Discover e.

   x = 0:1/64:2;
   h = .0001;

   if nargin == 0
      initialize_graphics
      a = 2;
   else
      a = get_a;
   end

   % Compute y = a^x and its approximate derivative

   p = flipud(get(gca,'children'));
   y = a.^x;
   yp = (a.^(x+h) - a.^x)/h;

   % Update the plot.

   set(p(1),'ydata',y)
   set(p(2),'ydata',yp)
   set(p(3),'string',sprintf('a = %5.3f',a))

   % ----------------------------------

   function initialize_graphics
      clf
      shg
      plot(x,ones(2,length(x)));
      axis([0 2 0 8])
      set(gcf, ...
         'windowbuttondownfcn', ...
         'set(gcf,''windowbuttonmotionfcn'',''expgui(0)'')', ...
         'windowbuttonupfcn', ...
         'set(gcf,''windowbuttonmotionfcn'',[])');
      fs = get(0,'defaulttextfontsize')+2;
      text(0.3,6.0,'a = 0','fontsize',fs,'fontweight','bold')
      title('y = a^x','fontsize',fs,'fontweight','bold')
      legend('y','dy/dx','location','northwest')
      xlabel('x')
      ylabel('y')
   end

   % ----------------------------------

   function a = get_a
      point = get(gca,'currentpoint');
      xa = point(1,1);
      ya = point(1,2);
      a = ya^(1/xa);
   end

end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -