Why I am having complex numbers when I am using LSQNONLIN??
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi Guys,
Maybe the question seems silly but any help is welcome. I am trying to determine some parameters minimizing the error between my analytical force (function: fun), and the experimental force, F, using lsqnonlin. My analytical force is a function of displacement, u, velocity, u_der1, the derivative of the experimental force, F_der1, and the unknown parameters k(1), k(2), k(3), and k(4) which I am trying to determine.
When k(4)=1, then the analytical force is assumed linear and all the results are fine and within the constraints I have defined. However, when k(4) is not equal to 1 (and the force is not linear any more)the corresponding results for k(1), k(2), k(3), and k(4)are complex numbers and sometimes negative and outside the constraints I have defined, and therefore these results don't have any physical neaning. How I can have real and positive results like in the linear case?
fun = @(k)k(3)*(u.^(k(4)))+ (k(2)).*u_der1+...
(k(3)*k(4).*(u.^(k(4)-1)).*k(2)/k(1)).*u_der1-(k(2)/k(1)).*F_der1-F
k0_assumption=[1; 1; 1; 1]
lb=0.8*[k0_assumption(1); k0_assumption(2); k0_assumption(3); k0_assumption(4) ];
ub=1.2*[k0_assumption(1); k0_assumption(2); k0_assumption(3); k0_assumption(4) ];
k =lsqnonlin(fun,k0_assumption,lb,ub)
Christos
1 Commento
Risposte (1)
Matt J
il 16 Feb 2016
In addition to what Torsten commented, it looks like k(4) should be given a lower bound strictly greater than 1. Otherwise, the term (u.^(k(4)-1)) will be problematic. Also bear in mind that lsqnonlin may not obey your lb,ub bounds at all iterations. It may only satisfy the bound constraints asymptotically. You might want to try using fmincon instead with the SQP or interior-point algorithm, which can satisfy bounds at all iterations.
6 Commenti
Matt J
il 17 Feb 2016
I don't see why that would be true, generally. If you're getting complex numbers for force calculations, it would seem to me that you're using an equation outside the domain where it is physically valid.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!