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:
complex x using lsqnonlin optimisation

Subject: complex x using lsqnonlin optimisation

From: nirav darji

Date: 26 Nov, 2010 15:30:06

Message: 1 of 5

I have trouble calculatin complex "x" value using " lsqnonlin " algorithm.
I have A matrix with 1000 (complex data) raw and 8 column and B matrix with same 1000 Raw (target matrix) and 8 column.
I want to use equatin |Ax| - |B| = 0.
here my A is complex number.
I want to find 8 complex 'x' values using this lsqnonlin algorithm.
i use following code to find x but it gives me only real 'x'

x1 = lsqnonlin(@(x) myfun1(x,a,s1),[90])

function F = myfun1(x,a,s)
 F =abs(a*x)-abs(s);

Can anybody help me how to get find COMPLEX 'x'.
Thank you
Nirav

Subject: complex x using lsqnonlin optimisation

From: nirav darji

Date: 2 Dec, 2010 15:28:05

Message: 2 of 5

"nirav darji" <nirav_bme@yahoo.co.in> wrote in message <icojpu$om6$1@fred.mathworks.com>...
> I have trouble calculatin complex "x" value using " lsqnonlin " algorithm.
> I have A matrix with 1000 (complex data) raw and 8 column and B matrix with same 1000 Raw (target matrix) and 8 column.
> I want to use equatin |Ax| - |B| = 0.
> here my A is complex number.
> I want to find 8 complex 'x' values using this lsqnonlin algorithm.
> i use following code to find x but it gives me only real 'x'
>
> x1 = lsqnonlin(@(x) myfun1(x,a,s1),[90])
>
> function F = myfun1(x,a,s)
> F =abs(a*x)-abs(s);
>
> Can anybody help me how to get find COMPLEX 'x'.
> Thank you
> Nirav


Nobody in metlab central has answer about this question?
can somebody help me out in this metter please?
It going to be really helpful to me.
Thank you

Regards,
nirav

Subject: complex x using lsqnonlin optimisation

From: Torsten Hennig

Date: 2 Dec, 2010 15:48:54

Message: 3 of 5

> I have trouble calculatin complex "x" value using "
> lsqnonlin " algorithm.
> I have A matrix with 1000 (complex data) raw and 8
> column and B matrix with same 1000 Raw (target
> matrix) and 8 column.
> I want to use equatin |Ax| - |B| = 0.
> here my A is complex number.

I don't understand this equation.
Ax is a vector and B is a matrix ?
Maybe you want to minimze ||A*x - b|| where A
is a matrix and b is a vector ?

> I want to find 8 complex 'x' values using this
> lsqnonlin algorithm.
> i use following code to find x but it gives me only
> real 'x'
>
> x1 = lsqnonlin(@(x) myfun1(x,a,s1),[90])
>
> function F = myfun1(x,a,s)
> F =abs(a*x)-abs(s);
>
> Can anybody help me how to get find COMPLEX 'x'.
> Thank you
> Nirav

Subject: complex x using lsqnonlin optimisation

From: mahdi

Date: 30 Apr, 2011 12:53:24

Message: 4 of 5

Hi
I think you should divide it into two seperate variable as x=x1+i*x2 next you should find the values of x1 and x2

Subject: complex x using lsqnonlin optimisation

From: Roger Stafford

Date: 30 Apr, 2011 19:50:22

Message: 5 of 5

"nirav darji" <nirav_bme@yahoo.co.in> wrote in message <icojpu$om6$1@fred.mathworks.com>...
> .......
> x1 = lsqnonlin(@(x) myfun1(x,a,s1),[90])
> function F = myfun1(x,a,s)
> F =abs(a*x)-abs(s);
> .......
- - - - - - - - -
  Are you sure it is only abs(a*x)-abs(s) you want to minimize in the least squares sense? That is a weak requirement which does not necessarily bring a*x and s close together. They will have approximately the same magnitude but the phase angle would in general be very different.

  If instead you use the stronger requirement of minimizing abs(a*x-s) (in the least squares sense,) that would be a linear problem which could readily be solved using matlab's matrix left division (back slash) and you wouldn't need to use 'lsqnonlin' at all.

Roger Stafford

Tags for this Thread

No tags are associated with 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