[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What to give as "real column vector of initial parameters" to nonlin
From: |
Kai Torben Ohlhus |
Subject: |
Re: What to give as "real column vector of initial parameters" to nonlin_curvefit? |
Date: |
Fri, 12 Jun 2020 14:27:18 +0900 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 |
On 6/12/20 2:20 AM, Doron Behar wrote:> [...]
> Since I'm already here, perhaps you could help me a bit further:
>
> I set this parametric function:
>
> harmonic_param_func = @(p, t) p(1) * exp(-t/(2 * p(2))) *
cos(p(3)*t + p(4))
>
> And I call nonlin_curvefit like this:
>
> [p, fy, cvg, outp] = nonlin_curvefit( ...
> harmonic_param_func, [ ...
> guessed_max_amplitude; ...
> guessed_tau; ...
> guessed_period; ...
> guessed_phase
> ], ...
> counts, times ...
> );
>
> Where the variables guessed_* are corresponding values I think may be a
> good starting guess for the fitting algorithm. But I get this error when
> I call it as so:
>
> error: NA: invalid class name
> error: called from
> __nonlin_residmin__ at line 212 column 21
> nonlin_curvefit at line 83 column 22
> ./harmonic-oscillator.m at line 50 column 21
>
> And if I use `,` instead of `;` I get the error:
>
> error: initial parameters must be either a structure or a column
vector
> error: called from
> __nonlin_residmin__ at line 101 column 7
> nonlin_curvefit at line 83 column 22
> ./harmonic-oscillator.m at line 50 column 21
>
> Maybe I'm just not fluent yet in octave's / matlab's data types. But,
> the 2nd error intrigued me more: Is it possible to use a struct where my
> `p` is, in the fitting function? If so that's sound like another
> undocumented detail of the function?
>
> Doron.
You function call does not look that wrong, but the devil is in the
detail. Can you sent us a minimal working example containing all
"guessed_*" values and "counts", "times"?
Kai