## How to input and solve non-linear system of equations in a matrix form

### Marko (view profile)

on 5 Dec 2012
Latest activity Commented on by John BG

### John BG (view profile)

on 16 Feb 2016

Hi!

I am trying to solve the following system of non-linear equations in Matlab and I am stucked with it for a few days...

(x_Tx - x_Rx_i).^2 + (y_Tx - y_Rx_i).^2 = 10.^( (P_Tx - P_L0 - P_Rx_i) / 5n )

Unknowns are:

x_Tx (Transmitter x location)

y_TX (Transmitter y location)

P_Tx (Transmitter power)

Knowns are:

x_Rx_i (measuremetns' x location) - vector of i elements

y_Rx_i (measurements' y location) - vector of i elements

P_Rx_i (received power at locations x_Rx_i, y_Rx_i ) - vector of i elements

P_L0 (reference power) - scalar

n (path loss coeficient) - scalar

i (number of measurement points at locations x_Rx_i, y_Rx_i and received power P_Rx_i )

My questions are:

1. How to input such non-linear system of equations into Matlab in a matrix form?

2. Which functions can be used to solve this?

## Products

No products are associated with this question.

### Babak (view profile)

on 5 Dec 2012

Offcourse you cannot write a nonlinear equation in a matrix form.

Matrix form is only possible for linear sets of equations.

You need to use a nonlinear equation solver or you write one yourself. If you have license to MAATLAB's Optimization toolbox (check it by giving the >>ver command in the command window) then you can use the command fsolve().

By the way, you need to have at least as many equations as the number of your unknowns, which doesn't seem true in your case. If x_Tx, y_Tx, P_Tx are scalar (for example), you have only one equation but 3 unknown. If they are vectors of 2 element, you have 2 equations but 6 unknowns.. Please check your equations again because I think you need to have more equations.

John Petersen

### John Petersen (view profile)

on 5 Dec 2012

Not 3n unknowns. Just 3. The unknowns are scalars.

Babak

### Babak (view profile)

on 5 Dec 2012

I don't understand. There is only one equation and he is using the notation .^ repeatedly which gives the impression that there are vectors under the operator .^ but obviously there are 3 unknowns and 1 equation...

Marko: You need to find more equations because only 1 equation for 3 unknowns is not sufficient.

John BG

### John BG (view profile)

on 16 Feb 2016

set 1 parameter as variable and set the other 2 constant, have a look, then sweep one of the parameters you set as constant before, and repeat for the other one, you obtain 3 sets of curves

### Marko (view profile)

on 5 Dec 2012

That's right I have always 3+ elements in vectors thus I have the same or even more equations than unknowns...

So how to input all these equations into Matlab to use them e.g. with fsolve()?

I can't put them in manually if I have few 100 or 1000 elements in vectors

I need to input them somehow with matrices of coefficients, etc... and I don't know how to do this...

And yes, all these unknowns are scalars while I have the Transmitter on location x_Tx,y_Tx, which is transmitting with the power P_Tx...

x_Tx (Transmitter x location) - scalar

y_TX (Transmitter y location) - scalar

P_Tx (Transmitter power) - scalar

#### Join the 15-year community celebration.

Play games and win prizes!

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