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

조회 수: 3 (최근 30일)
Christos
Christos 2016년 2월 16일
편집: Matt J 2016년 2월 17일
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