MATLAB: Solving simultaneous equations numerically

equationssimultaneoussummation

I have two equations that need to be solved numerically, I can't write out the equations explicitly but they are both of the form:
x = \sum_{i=1}^N (a-(b_i)x)/((a-(b_i)x)^2+q^2y^2)
All the parameters other than x and y are fixed in this equation. Both my equations are of similar forms but I'm not sure what is the best way to solve this numerically in MATLAB as these equations involve the summation and I have never dealt with this kind of equation in MATLAB before.
p.s. sorry for the mess but I hope the form of the equation is clear enough. Thanks.

Best Answer

Here is what you need to do
1) write a function like this:
funX=@(x,y,N,a,q) sum((a-b.*x)./((a-b.*x).^2+q.^2.*y.^2));
funY=@(x,y,N,a,q) whatever the equation is for Y
fun1=@(x,y,N,a,q) ([funX(x,y,N,a,q); ...
funY(x,y,N,a,q)]);
Note that fun1 is the right-hand-side of your equation. (correct it if I miss code it)
2) use "fsolve" or another method of your choice to solve it as follow
a= 'the value you want'
N= 'the value you want'
q= 'the value you want'
%Your first equation is x=FunX based on your question.
%Assuming your second equation is also of the form y=FunY
%P=[x;y] so P(1)=x and P(2)=y;
fun2=@(P) (P-fun1(P(1),P(2),N,a,q))
InitialGuess=[x0;y0];
fsolve(fun2,InitialGuess)
This way, you can change N, a, q programitically