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

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 Comment

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.

Sign in to comment.

Answers (1)

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 Comments

Thank you for the answers. I had a more careful look, and while I agree with Torsten, I can't find any reason why I would have problem if k(4) is less than 1, and correspondingly the power of the displacement negative. I think my only problem would be how to define the force in terms of complex numbers, even though I suppose I should be mainly interested in the magnitude of the force (sqrt(real_part^2+imaginary_part^2)).
Well, the problem would be if u=0, then you have a serious discontinuity at k(4)=1:
>> u=0; k=1+eps; u^(k-1)
ans =
0
>> u=0; k=1; u^(k-1)
ans =
1
>> u=0; k=1-eps; u^(k-1)
ans =
Inf
Thanks again. However, do you know if the assumption I made in the previous comment is rational or not (how to define the force in terms of complex numbers, even though I suppose I should be mainly interested in the magnitude of the force (sqrt(real_part^2+imaginary_part^2))).
I think you're the only one who understands the physics behind the model equation you've shown.
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.
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.

Sign in to comment.

Asked:

on 16 Feb 2016

Edited:

on 17 Feb 2016

Community Treasure Hunt

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

Start Hunting!