how to solve one variable in non linear equation?

조회 수: 3 (최근 30일)
M.Rameswari Sudha
M.Rameswari Sudha 2023년 1월 12일
댓글: M.Rameswari Sudha 2023년 1월 12일
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)

채택된 답변

Torsten
Torsten 2023년 1월 12일
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

추가 답변 (1개)

VBBV
VBBV 2023년 1월 12일
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
M.Rameswari Sudha
M.Rameswari Sudha 2023년 1월 12일
I want to solve t1 from h. No need to find h value. Help me
VBBV
VBBV 2023년 1월 12일
Read about fsolve for more info. Try with different initial values. I have shown an e.g.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Numbers and Precision에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by