Why I am having complex numbers when I am using LSQNONLIN??

1 次查看(过去 30 天)
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 个评论
Torsten
Torsten 2016-2-16
编辑:Torsten 2016-2-16
Raise a negative number to a real power and you'll get something complex. Thus I suspect that your displacement vector contains some negative elements.
Best wishes
Torsten.

请先登录,再进行评论。

回答(1 个)

Matt J
Matt J 2016-2-16
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 个评论
Christos
Christos 2016-2-16
I meant that generally speaking, and not specifically about my model, if you try to fit the experimental data to your analytical model (lets say F=k*u^0.2) and the corresponding k parameter and therefore the analytical forces you are getting are complex numbers then I suppose you are only interested to their magnitude.
Matt J
Matt J 2016-2-17
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Nonlinear Least Squares (Curve Fitting) 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by