help-octave
[Top][All Lists]
Advanced

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

Re: leasqr and anonymous functions


From: Olaf Till
Subject: Re: leasqr and anonymous functions
Date: Wed, 30 Apr 2008 08:31:43 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

On Tue, Apr 29, 2008 at 07:58:48PM -0700, Nose Nada wrote:
> 
> Hello there!
> 
> I have defined an anonymous function Error with three parameters (SD(1:3))
> and an independent variable p:
> 
> octave:1> SDc = 0.0001; R=1000;
> octave:2> Error = @(SD,p)(SDc^2 + ((1/(R-1) + p).^2)*(SD(1)^2) +
> (((p./((2*(SD(3)^1.5) + 0.6))).*log(1+(10^SD(3)).*(1-p))).^2).*(SD(2)^2));
> 
> It worked fine on evaluation:
> 
> octave:3> Error([0.01 0.01 1], 0:0.1:1) 
> ans =
> 
>    1.0100e-08   1.8144e-06   6.9068e-06   1.4827e-05   2.5052e-05  
> 3.6983e-05   4.9925e-05   6.3081e-05   7.5597e-05   8.6947e-05   1.0021e-04
> 
> However, when I tried to fit it to experimental data using 'leasqr', it
> fails:
> 
> octave:4> leasqr((0:0.1:1)',(0.001:0.001:0.011)', [0.01 0.01 1], Error)
> error: operator -: nonconformant arguments (op1 is 11x1, op2 is 3x1)
> error: evaluating binary operator `-' near line 182, column 9
> error: evaluating binary operator `.*' near line 182, column 5
> error: evaluating assignment expression near line 182, column 2
> error: called from `leasqr' in file
> `/usr/share/octave/packages/optim-1.0.0/leasqr.m'
> 
> 
Have not looked thoroughly through your function Error, but it seems
to have its arguments in the wrong order. Although the second argument
is named 'p', the function seems to treat it as the data, not the
parameters. leasqr calles Error with p = [0.01 0.01 1], so error
returns only 3 values instead of 11.

Olaf


reply via email to

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