- 5*x^2 + x*y = 4
- y^2 + z = 2
- x + 2*z = 0

- 5*x^2 + x*y - 4 = 0
- y^2 + z - 2 = 0
- x + 2*z = 0

3 views (last 30 days)

Eduard Reitmann
on 3 Aug 2018

Edited: Eduard Reitmann
on 3 Aug 2018

Step 1: Rewrite each equation to add to zero. For example:

- 5*x^2 + x*y = 4
- y^2 + z = 2
- x + 2*z = 0

becomes:

- 5*x^2 + x*y - 4 = 0
- y^2 + z - 2 = 0
- x + 2*z = 0

Write to function.

f = @(x,y,z) [5*x.^2+x.*y-4;

y.^2+z-2;

x+2*z];

Step 2: Iteratively solve using fminsearch.

fun = @(x) sum(f(x(1),x(2),x(3)).^2);

x0 = [0;0;0];

x = fminsearch(fun,x0)

Opportunities for recent engineering grads.

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

Start Hunting!
## 4 Comments

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/413236-how-to-solve-for-three-equations-from-a-large-array-of-equations#comment_595800

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/413236-how-to-solve-for-three-equations-from-a-large-array-of-equations#comment_595800

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/413236-how-to-solve-for-three-equations-from-a-large-array-of-equations#comment_595842

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/413236-how-to-solve-for-three-equations-from-a-large-array-of-equations#comment_595842

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/413236-how-to-solve-for-three-equations-from-a-large-array-of-equations#comment_596016

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/413236-how-to-solve-for-three-equations-from-a-large-array-of-equations#comment_596016

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/413236-how-to-solve-for-three-equations-from-a-large-array-of-equations#comment_596082

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/413236-how-to-solve-for-three-equations-from-a-large-array-of-equations#comment_596082

Sign in to comment.