Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. %% model function:
  2. F = @ (x, p) p(1) * exp (p(2) * x);
  3. %% independents and dependents:
  4. x = 1:5;
  5. y = [1, 2, 4, 7, 14];
  6. %% initial values:
  7. init = [.25; .25];
  8. %% other configuration (default values):
  9. tolerance = .0001;
  10. max_iterations = 20;
  11. weights = ones (1, 5);
  12. dp = [.001; .001]; % bidirectional numeric gradient stepsize
  13. dFdp = "dfdp"; % function for gradient (numerical)
  14.  
  15. %% linear constraints, A.' * parametervector + B >= 0
  16. A = [1; -1]; B = 0; % p(1) >= p(2);
  17. options.inequc = {A, B};
  18.  
  19. %% start leasqr, be sure that 'verbose' is not set
  20. global verbose; verbose = false;
  21. [f, p, cvg, iter] = ...
  22. leasqr (x, y, init, F, tolerance, max_iterations, ...
  23. weights, dp, dFdp, options)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement