how to solve one variable in non linear equation?

5 views (last 30 days)
In my coding I couldn't get the value for t1. I get the answer in cubic equation of another variable z. But I didn't use z anywhere in my codind. Anyone help and tell how to get the answer for t1.
clc
clear all
T=12; u1=4;u2=8;a=30;b=5;a2=100;A=500;c2=10;c3=12;c4=8;D0=115; b2=0.2;
a=0.01;d=0.2;m=0.5;k1=0.5;k0=1;k2=2;
syms t1
c1=5;
h=(1./T).*(c1.*((b-a)-b.*t1-(a+b.*(1+m)./(1+m-t1)))+c2.*(b.*t1-(a+b.*(1+m)).*(t1./(1+m-t1)))+c3.*((a./k1)-((b./k1.^2).*(1-k1.*T)).*(((-u1.*k1)./(1+k1.*(t1-T))+1)-((1-k1.*T)./(1+k1.*(t1-T)))+(b.*k0.*(t1-u1)./k1)-(a-(b.*k0.*(1-k1.*T)./k1)).*((u2-u1)./(1+k1.*(t1-T)))+(k0.*D0./k1).*((k1.*(u1-u2)./(1+k1.*(t1-T)))-(a-(b.*k0./k1).*(1-k1.*T)).*((T-k2)./(1+k1.*(t1-T)))+(b.*k0./k1).*(u2-T)-(1-k1.*T).*((T+u2)./(1+k1.*(t1-T)))+c4.*(-a2+b2.*t1+k0.*(a-(b./k1).*(1-k1.*T).*(1./(1+k1.*(t1-T))+(b./k1))))))));
t1=solve(h)
disp(t1)

Accepted Answer

Torsten
Torsten on 12 Jan 2023
T=12; u1=400;u2=8;a=30;b=5;a2=100;A=500;c2=10;c3=12;c4=8;D0=115; b2=0.2;
a=-1.1;d=11.2;m=-0.5;k1=1.5;k0=1.1;k2=2;
syms t1
c1=5;
h= (1./T).*(c1.*((b-a)-b.*t1-(a+b.*(1+m)./(1+m-t1)))+c2.*(b.*t1-(a+b.*(1+m)).*(t1./(1+m-t1)))+c3.*((a./k1)-((b./k1.^2).*(1-k1.*T)).*(((-u1.*k1)./(1+k1.*(t1-T))+1)-((1-k1.*T)./(1+k1.*(t1-T)))+(b.*k0.*(t1-u1)./k1)-(a-(b.*k0.*(1-k1.*T)./k1)).*((u2-u1)./(1+k1.*(t1-T)))+(k0.*D0./k1).*((k1.*(u1-u2)./(1+k1.*(t1-T)))-(a-(b.*k0./k1).*(1-k1.*T)).*((T-k2)./(1+k1.*(t1-T)))+(b.*k0./k1).*(u2-T)-(1-k1.*T).*((T+u2)./(1+k1.*(t1-T)))+c4.*(-a2+b2.*t1+k0.*(a-(b./k1).*(1-k1.*T).*(1./(1+k1.*(t1-T))+(b./k1))))))));
t1=vpasolve(h,t1,[0 1])
t1 = 
0.4999993236378365887378927054944
double(subs(h,t1))
ans = 2.2769e-24

More Answers (1)

VBBV
VBBV on 12 Jan 2023
clc
clear all
T=12; u1=400;u2=8;a=30;b=5;a2=100;A=500;c2=10;c3=12;c4=8;D0=115; b2=0.2;
a=-1.1;d=11.2;m=-0.5;k1=1.5;k0=1.1;k2=2;
syms t1
c1=5;
h=@(t1) (1./T).*(c1.*((b-a)-b.*t1-(a+b.*(1+m)./(1+m-t1)))+c2.*(b.*t1-(a+b.*(1+m)).*(t1./(1+m-t1)))+c3.*((a./k1)-((b./k1.^2).*(1-k1.*T)).*(((-u1.*k1)./(1+k1.*(t1-T))+1)-((1-k1.*T)./(1+k1.*(t1-T)))+(b.*k0.*(t1-u1)./k1)-(a-(b.*k0.*(1-k1.*T)./k1)).*((u2-u1)./(1+k1.*(t1-T)))+(k0.*D0./k1).*((k1.*(u1-u2)./(1+k1.*(t1-T)))-(a-(b.*k0./k1).*(1-k1.*T)).*((T-k2)./(1+k1.*(t1-T)))+(b.*k0./k1).*(u2-T)-(1-k1.*T).*((T+u2)./(1+k1.*(t1-T)))+c4.*(-a2+b2.*t1+k0.*(a-(b./k1).*(1-k1.*T).*(1./(1+k1.*(t1-T))+(b./k1))))))));
t1=fsolve(h,[0 1])
Equation solved, solver stalled. fsolve stopped because the relative size of the current step is less than the value of the step size tolerance squared and the vector of function values is near zero as measured by the value of the function tolerance.
t1 = 1×2
10.4643 10.4643
disp(t1)
10.4643 10.4643
  4 Comments
M.Rameswari Sudha
M.Rameswari Sudha on 12 Jan 2023
I want to solve t1 from h. No need to find h value. Help me
VBBV
VBBV on 12 Jan 2023
Read about fsolve for more info. Try with different initial values. I have shown an e.g.

Sign in to comment.

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!