|
From: | RICHARD Dominique |
Subject: | testing lsqcurvefit |
Date: | Thu, 6 Apr 2017 11:32:35 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 |
Hello, I wanted to test the function lsqcurvefit (of the optim package) bu when I tried to run the example found at the bottom of the Octave-Forge page, I got an error : "error: 'p' undefined near line 4 column 9". What's wrong with this example ? %% Example for user specified Jacobian. %% model function: function [F,J] = myfun (p, x) F = p(1) * exp (-p(2) * x); if nargout > 1 J = [exp(- p(2) * x), - p(1) * x .* exp(- p(2) * x)]; endif endfunction %% independents x = [1:10:100]'; %% observed data y =[9.2160e-001, 3.3170e-001, 8.9789e-002, 2.8480e-002, 2.6055e-002,... 8.3641e-003, 4.2362e-003, 3.1693e-003, 1.4739e-004, 2.9406e-004]'; %% initial values: p0=[0.8; 0.05]; %% bounds lb=[0; 0]; ub=[]; %% Jacobian setting opts = optimset ("Jacobian", "on") [c, resnorm, residual, flag, output, lambda, jacob] = ... lsqcurvefit (@ (varargin) myfun(varargin{:}), p0, x, y, lb, ub, opts) -- Dominique RICHARD Laboratoire de Génie des Procédés Catalytiques - CNRS-CPE Lyon 3, rue Victor Grignard F-69616 Villeurbanne cedex Tél. (33) 4 72 43 17 52 - Fax (33) 4 72 43 16 73 |
[Prev in Thread] | Current Thread | [Next in Thread] |