help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help in parameter estimation


From: Nicholas Jankowski
Subject: Re: Help in parameter estimation
Date: Tue, 30 Aug 2016 11:56:55 -0400

error: leasqr: subscript indices must be either positive integers less than 2^31 or logicals
>
>
>> error: called from
>>     leasqr at line 329 column 9
>>
>

Since it's giving that error pointing out line 329 within leasqr I don't think he's shadowing the function.

Bharath:

ok, I removed the definitions for x, p and pin from the function f, as there's no point in passing it values of f if the function is setting them anyway.  So:

function F = f(x,p)
  typeinfo(x)
  m(1,1)=20;
  for i=1:length(x)
    m(i+1,1)=((p(1)-m(i,1))/(p(2)*p(3))+((p(4)*x(i,2)*(x(i,3)-m(i,1)))+(p(5)*x(i,4))+(p(6)*x(i,5)))/(p(3))+p(7))+m(i,1);
  endfor
  F=m(2:end);
endfunction

>>x = [19.54533     0.00000    21.33717     0.00000     0.60320;
    19.30000     0.00000    21.28817     0.00000     0.66134;
    19.30000     0.00000    20.55900     0.00000     0.71948;
    19.13750     0.00000    21.21883     0.00000     0.77762;
    19.00000     0.00000    20.68650     0.00000     0.83576];

>> p = [20, 1, 100, 1, 0.001, 1, 0.01];

>> pin=[p(1);p(2);p(3);p(4);p(5);p(6);p(7)];

>> f(x,p)
ans = matrix
ans =

   20.016
   20.032
   20.049
   20.067
   20.084

>> [L,p,cvg,iter]=leasqr(x,y,pin,f)
error: 'y' undefined near line 1 column 24
error: evaluating argument list element number 2

oops, forgot to ask for testvalues for y.

for now, just using y = f(x,p)

>> [L,p,cvg,iter]=leasqr(x,f(x,p),pin,f)

>> leasqr(x,f(x,p),pin,f)
ans = matrix
error: 'x' undefined near line 2 column 12
error: called from
    f at line 2 column 3
error: evaluating argument list element number 1
error: called from
    f at line 2 column 3
error: evaluating argument list element number 4


NOW, adding the @f as I said before (it also works with 'f' ):


>> [L,p,cvg,iter]=leasqr(x,f(x,p),pin,@f)
ans = matrix
ans = matrix
ans = matrix
ans = matrix
ans = matrix
ans = matrix
ans = matrix
ans = matrix
ans = matrix
ans = matrix
ans = matrix
ans = matrix
ans = matrix
ans = matrix
ans = matrix
ans = matrix
L =

   20.016
   20.032
   20.049
   20.067
   20.084

p =

  2.0000e+001
  1.0000e+000
  1.0000e+002
  1.0000e+000
  1.0000e-003
  1.0000e+000
  1.0000e-002

cvg =  1
iter =  1


so, it works, and once the input arguments were straightened out you get a result.  Since I don't know what your data and function really are, I'm not in a position to evaluate whether the output is 'right'.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]