Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to deal with complex nonlinear least square problem?

Subject: How to deal with complex nonlinear least square problem?

From: flying

Date: 26 Nov, 2012 12:52:09

Message: 1 of 5

Hi all,
      I have ecountered a problem recently.It's something about 'complex nonlinear least square'. For instance,we want to minimize object function
       y = min|3+4i - x^2|^2 ,where i = sqrt(-1),x is a variable
How can i get 'x' by using matlab function 'lsqnonlin'?
If there are more variables,how can i figure this out?

Anticipating your reply,thanks!

Sincerely
Frank
       

Subject: How to deal with complex nonlinear least square problem?

From: Torsten

Date: 26 Nov, 2012 13:15:08

Message: 2 of 5

"flying" wrote in message <k8volo$2rm$1@newscl01ah.mathworks.com>...
> Hi all,
> I have ecountered a problem recently.It's something about 'complex nonlinear least square'. For instance,we want to minimize object function
> y = min|3+4i - x^2|^2 ,where i = sqrt(-1),x is a variable
> How can i get 'x' by using matlab function 'lsqnonlin'?
> If there are more variables,how can i figure this out?
>
> Anticipating your reply,thanks!
>
> Sincerely
> Frank
>

Hint:
|a+i*b|^2 = a^2 + b^2
for real numbers a and b.

Best wishes
Torsten.
        

Subject: How to deal with complex nonlinear least square problem?

From: flying

Date: 28 Nov, 2012 14:14:15

Message: 3 of 5

Thank you very much!

   I've encountered another problem.I met the error "optimization terminated norm of the current step is less than options tolx" when i use 'lsqnonlin' function.This means that the outcome is the same as the initial values i set,so how to deal with it?

   Sincerely
   frank

Subject: How to deal with complex nonlinear least square problem?

From: Torsten

Date: 28 Nov, 2012 14:55:17

Message: 4 of 5

"flying" wrote in message <k9567n$lea$1@newscl01ah.mathworks.com>...
> Thank you very much!
>
> I've encountered another problem.I met the error "optimization terminated norm of the current step is less than options tolx" when i use 'lsqnonlin' function.This means that the outcome is the same as the initial values i set,so how to deal with it?
>
> Sincerely
> frank

There seems to be an error in your problem set-up, but nothing useful can be said
unless we see the relevant part of your MATLAB code.

Best wishes
Torsten.

Subject: How to deal with complex nonlinear least square problem?

From: flying

Date: 29 Nov, 2012 02:06:20

Message: 5 of 5

"Torsten" wrote in message <k958kk$1mm$1@newscl01ah.mathworks.com>...
> "flying" wrote in message <k9567n$lea$1@newscl01ah.mathworks.com>...
> > Thank you very much!
> >
> > I've encountered another problem.I met the error "optimization terminated norm of the current step is less than options tolx" when i use 'lsqnonlin' function.This means that the outcome is the same as the initial values i set,so how to deal with it?
> >
> > Sincerely
> > frank
>
> There seems to be an error in your problem set-up, but nothing useful can be said
> unless we see the relevant part of your MATLAB code.
>
> Best wishes
> Torsten.

My code is to deal with a multivariables problem.There are many parameters to be optimized.The vectors: 'sigAmpEst' 'alphaEst' 'rEst' have the same dimension.
My problem is that i only get the initial parameters when i use 'lsqnonlin',maybe the model to be optimized is too complicated or the parameters to be estimated is too many.I don' t konw why,any good idea?

options = optimset('Display','iter','MaxFunEvals',5e3,'MaxIter',1000,'TolFun',1e-7,'TolX',1e-11);
[x,renorm,residual,exitflag,output] = lsqnonlin(@lsqnonlinCE,[real(sigAmpEst) imag(sigAmpEst) alphaEst rEst],[],[],options);


function y=lsqnonlinCE(z)
% Function used in 'lsqnonlin.m'

global pi2 c lj yk1 yk2 fk1 fk2 sigAmpEst

N = length(sigAmpEst);
NL = length(yk1);
NH = length(yk2);
ykce1 =[];
ykes1 =[];
for ii = 1:NL
    for jj = 1:N
        ykce1 = [ykce1 (z(jj) + lj*z(jj+N))*exp(-z(jj+2*N)*fk1(ii))*exp(-lj*2*pi2*z(jj+3*N)*fk1(ii)/c)];
    end
    ykce1 = sum(ykce1);
    ykes1 = [ykes1 abs(yk1(ii) -ykce1)];
end
 
ykce2 =[];
ykes2 =[];
for ii =1:NH
    for jj = 1:N
        ykce2 = [ykce2 (z(jj) + lj*z(jj+N))*exp(-z(jj+2*N)*fk2(ii))*exp(-lj*2*pi2*z(jj+3*N)*fk2(ii)/c)];
    end
    ykce2 = sum(ykce2);
    ykes2 = [ykes2 abs(yk2(ii) -ykce2)];
end
  
y = [ykes1 ykes2];
 
 
 
Sincerely
Frank

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us