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

📄 a171.m

📁 matlab算法集 matlab算法集
💻 M
字号:
       %----------------------------------------------------------------
       % Example a1.7.1: Optimization
       %----------------------------------------------------------------

       % Initialize

       clc                 % clear command window
       clear               % clear variables
       global t y          % used by funa171.m
       q = [6 .5 2];       % nominal parameters       
       p = 100;            % number of points
       n = 3;              % number of variables
       t1 = 5;             % range of t
       noise = 0.25;       % measurement noise 
       x0 = [0 0 0]';      % initial guess
       tol = 1.e-4;        % error tolerance
       m = 200;            % maximum iterations
       v = n;              % order of method
       g = inline ('x(1)*exp(-x(2)*t) + x(3)','t','x');

       % Construct data

       fprintf ('Example a1.7.1: Optimization\n');
       randinit (1000)
       t = [0 : t1/(p-1) : t1]';
       y = g(t,q) + randu (p,1,-noise,noise);

       % Fit optimal curve

       disp ('Searching for optimal x ...')
       [x,ev,k] = conjgrad (x0,tol,v,m,'funa171');
       show ('Optimal x',x)
       show ('Optimal f(x)',funa171(x))
       show ('Iterations',k);
       show ('Function evaluations',ev);

       % Display optimal curve and data

       Y(:,1) = g(t,x);
       Y(:,2) = y;
       graphxy (t,Y,'Unconstrained Optimization','t','y')
       %----------------------------------------------------------------

⌨️ 快捷键说明

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