Info

This question is closed. Reopen it to edit or answer.

system of nonlinear equation

2 views (last 30 days)
paDideh
paDideh on 7 Aug 2020
Closed: MATLAB Answer Bot on 20 Aug 2021
Hello;
I have a system of 5 nonlinear equations that I try to solve with fsolve but I cant, can you help me pls?
where x(1),...,x(5) are the unknowns and "Rho -Bo- Br -beta(N) -beta(L) -gamma- c - alpha -Phi- Eta -K -W " are parameters. So i want x(1),...,x(5) to be dependent by "Rho Bo Br betaa(N) betaa(L) gammaa c alphaa Phi Eta K W "
F(1)= K*alpha + Rho*(x(3) - x(1)) + x(2)^(1/2)*beta(L) + x(4)^(1/2)*beta(N) - (x(1) - W)*(Br + Rho) - Br*x(1);
F(2)= (beta(L)*(x(1) - W))/(2*x(2)^(1/2)) - x(2);
F(3)= Phi*x(5) - Rho*(x(3) - x(1)) + Rho*(W - c) + x(2)^(1/2)*gamma - alpha*(K - 1) + x(4)^(1/2)*beta(N) - (x(3) - c)*(Bo + Rho) - Bo*x(3);
F(4)= Phi*x(5) - Rho*(x(3) - x(1)) + Rho*(W - c) + x(2)^(1/2)*gamma - alpha*(K - 1) + x(4)^(1/2)*beta(N) - (x(3) - c)*(Bo + Rho) - Bo*x(3);
F(5)= Phi*(x(3) - c) - Eta*x(5);
I'm trying to run this code:
syms Rho Bo Br beta(N) beta(L) gamma c alpha Phi Eta K W
f=@(x)[K*alpha + Rho*(x(3) - x(1)) + x(2)^(1/2)*beta(L) + x(4)^(1/2)*beta(N) - (x(1) - W)*(Br + Rho) - Br*x(1);
(beta(L)*(x(1) - W))/(2*x(2)^(1/2)) - x(2);
Phi*x(5) - Rho*(x(3) - x(1)) + Rho*(W - c) + x(2)^(1/2)*gamma - alpha*(K - 1) + x(4)^(1/2)*beta(N) - (x(3) - c)*(Bo + Rho) - Bo*x(3);
(beta(N)*(x(3) - c))/(2*x(4)^(1/2)) - x(4) + (beta(N)*(W - c))/(2*x(4)^(1/2));Phi*(x(3) - c) - Eta*x(5)];
fsolve(f,[1 1 1 1 1])
but I get the following error:
Error using fsolve (line 269)
FSOLVE requires all values returned by functions to be of data type double.
Error in UntitledYTB (line 16)
fsolve(f,[1 1 1 1 1])
thanks a lot
  2 Comments
Stijn Haenen
Stijn Haenen on 7 Aug 2020
You also have to define what x is.
syms Rho Bo Br beta_N beta_L gamma c alpha Phi Eta K W
f=@(x)[K*alpha + Rho*(x(3) - x(1)) + x(2)^(1/2)*beta(L) + x(4)^(1/2)*beta(N) - (x(1) - W)*(Br + Rho) - Br*x(1);
(beta(L)*(x(1) - W))/(2*x(2)^(1/2)) - x(2);
Phi*x(5) - Rho*(x(3) - x(1)) + Rho*(W - c) + x(2)^(1/2)*gamma - alpha*(K - 1) + x(4)^(1/2)*beta(N) - (x(3) - c)*(Bo + Rho) - Bo*x(3);
(beta(N)*(x(3) - c))/(2*x(4)^(1/2)) - x(4) + (beta(N)*(W - c))/(2*x(4)^(1/2));Phi*(x(3) - c) - Eta*x(5)];
f_x=f(1:10)
Rho=1; Bo=1; Br=1; beta_N=1; beta_L=1; gamma=1; c=1; alpha=1; Phi=1; Eta=1; K=1; W=1;
subs(f_x)
paDideh
paDideh on 7 Aug 2020
thanks,I tried that but it didn't work.

Answers (0)

Community Treasure Hunt

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

Start Hunting!