Clear Filters
Clear Filters

I want to solve the unknown variable t1

1 view (last 30 days)
I want to solve t1 from the equation S1 and then apply value of t1 in TC. But I couldn't find t1. I don't know where I left the mistake.
clc
clear all
A0 =500;
D0=100;
c1=5;
c2=10;
c3=10;
c4=8;
a=30;
a2=40;
m=0.5;
b=5;
b2=7;
mu1=4;
mu2=8;
T=12;
k1=0.01;
k0=0.03;
syms t1
S1='(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.*(1-k1.*T)./k1^2).*(((-mu1.*k1)./(1+k1.*(t1-T)))+1)-((1-k1.*T)./(1+k1.*(t1-T)))+((b.*k0.*(t1-mu1))./k1)-((a-b.*k0.*(1-k1.*T))./k1).*((mu2-mu1)./(1+k1.*(t1-T)))+(k0.*D0./k1).*((k1.*(mu1-mu2)./(1+k1.*(t1-T)))-(a-((b.*k0.*(1-k1.*T))./k1)).*((T-k2)./(1+k1.*(t1-T)))+(b.*k0.*(mu2-T)./k1)-(1-k1.*T).*((T+mu2)./(1+k1.*(t1-T)))))+c4.*(-a2+b2.*t1+k0.*((a-b.*(1-k1.*T))./k1).*(1./(1+k1.*(t1-T)))+(b./k1)))';
t1=solve'S1'
TC=(1./T).*(A0+c1.*((b-a).*t1-(b.*t1^2./2)+(a+b.*(1+m)).*log((1+m-t1)./(1+m)))+c2.*((b.*t1^2./2)+(a+b.*(1+m)).*(t1+(1+m).*log(1+m-t1)))+c3.*((a./k1)-(b.*(1-k1.*T)./k1^2).*(mu1.*(log((1+k1.*(mu1-T))./(1+k1.*(t1-T)))-1)+t1)+((1-k1.*T)./k1).*(log((1+k1.*(mu1-T))./(1+k1.*(t1-T))))+(b.*k0./2.*k1).*(mu1-t1).^2+((a./k1)-(b.*k0.*(1-k1.*T)./k1^2).*(log((1+k1.*(mu1-T))./(1+k1.*(t1-T)))).*(mu2-mu1)+(k0.*D0./k1).*(mu2.*(log((1+k1.*(mu2-T))./(1+k1.*(t1-T)))-1)-mu1.*(log((1+k1.*(mu1-T))./(1+k1.*(t1-T)))-1)+((1-k1.*T)./k1).*(log((1+k1.*(mu2-T))./(1+k1.*(mu1-T))))+((a./k1)-(b.*k0.*(1-k1.*T)./k1^2).*(log((1+k1.*(mu1-T))./(1+k1.*(t1-T)))).*(T-mu2)+(b.*k0./k1).*(mu1-t1).*(T-mu2)+(k0.*D0./k1).*(log((1+k1.*(mu2-T))./(1+k1.*(mu1-T)))).*(T-mu2)-(k0.*b2./2.*k1).*(mu2-T).^2+((1./k1)-T)+(T-(1./k1)).*(T.*(log(1+k1(t1-T))-1)-mu2.*(log((1+k1.*(mu2-T))./(1+k1.*(t1-T)))-1))+(T-(1./k1)).*log(1+k1.*(mu2-T))))+c4.*(a.*(mu1-t1)+(b2./2).*(mu1.^2-t1.^2)-k0.*(a./k1)-(b.*(1-k1.*T)./k1^2).*(log((1+k1.*(mu1-T))./(1+k1.*(t1-T))))+(b./k1).*(mu1-t1))+D0.*(mu2-mu1)-(D0.*k0./k1).*(log((1+k1.*(mu2-T))./(1+k1.*(mu1-T))))+(1./2.*b2).*((a2-b2.*mu2).^2-(a2-b2.*T).^2)+k0.*a2.*log(1+k1.*(mu2-T))-(b2./k1).*(T-mu2)+(b2./k1).*(T-(1./k1)).*log(1+k1.*(mu2-T)))));
plot(t,TC)

Answers (1)

Alan Stevens
Alan Stevens on 12 Mar 2022
Well, this gets it working, though who knows if it makes any sense!"
A0 =500;
D0=100;
c1=5;
c2=10;
c3=10;
c4=8;
a=30;
a2=40;
m=0.5;
b=5;
b2=7;
mu1=4;
mu2=8;
T=12;
k1=0.01;
k0=0.03;
k2 = 0; % Replace with true value
syms t1
S1=(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.*(1-k1.*T)./k1^2).*(((-mu1.*k1)./(1+k1.*(t1-T)))+1)-((1-k1.*T)./(1+k1.*(t1-T)))+((b.*k0.*(t1-mu1))./k1)-((a-b.*k0.*(1-k1.*T))./k1).*((mu2-mu1)./(1+k1.*(t1-T)))+(k0.*D0./k1).*((k1.*(mu1-mu2)./(1+k1.*(t1-T)))-(a-((b.*k0.*(1-k1.*T))./k1)).*((T-k2)./(1+k1.*(t1-T)))+(b.*k0.*(mu2-T)./k1)-(1-k1.*T).*((T+mu2)./(1+k1.*(t1-T)))))+c4.*(-a2+b2.*t1+k0.*((a-b.*(1-k1.*T))./k1).*(1./(1+k1.*(t1-T)))+(b./k1)));
t1=solve(S1,t1);
TC=(1./T).*(A0+c1.*((b-a).*t1-(b.*t1.^2./2)+(a+b.*(1+m)).*log((1+m-t1)./(1+m)))+c2.*((b.*t1.^2./2)+(a+b.*(1+m)).*(t1+(1+m).*log(1+m-t1)))+c3.*((a./k1)-(b.*(1-k1.*T)./k1^2).*(mu1.*(log((1+k1.*(mu1-T))./(1+k1.*(t1-T)))-1)...
+t1)+((1-k1.*T)./k1).*(log((1+k1.*(mu1-T))./(1+k1.*(t1-T))))...
+(b.*k0./2.*k1).*(mu1-t1).^2+((a./k1)-(b.*k0.*(1-k1.*T)./k1^2).*(log((1+k1.*(mu1-T))./(1+k1.*(t1-T)))).*(mu2-mu1)+(k0.*D0./k1).*(mu2.*(log((1+k1.*(mu2-T))./(1+k1.*(t1-T)))-1)-mu1.*(log((1+k1.*(mu1-T))./(1+k1.*(t1-T)))-1)...
+((1-k1.*T)./k1).*(log((1+k1.*(mu2-T))./(1+k1.*(mu1-T))))+((a./k1)...
-(b.*k0.*(1-k1.*T)./k1^2).*(log((1+k1.*(mu1-T))./(1+k1.*(t1-T)))).*(T-mu2)...
+(b.*k0./k1).*(mu1-t1).*(T-mu2)+(k0.*D0./k1).*(log((1+k1.*(mu2-T))./(1+k1.*(mu1-T)))).*(T-mu2)-(k0.*b2./2.*k1).*(mu2-T).^2 ...
+((1./k1)-T)+(T-(1./k1)).*(T.*(log(1+k1.*(t1-T))-1) ...
-mu2.*(log((1+k1.*(mu2-T))./(1+k1.*(t1-T)))-1))+(T-(1./k1)).*log(1+k1.*(mu2-T))))...
+c4.*(a.*(mu1-t1)+(b2./2).*(mu1.^2-t1.^2)-k0.*(a./k1)...
-(b.*(1-k1.*T)./k1^2).*(log((1+k1.*(mu1-T))./(1+k1.*(t1-T))))...
+(b./k1).*(mu1-t1))+D0.*(mu2-mu1)-(D0.*k0./k1).*(log((1+k1.*(mu2-T))./(1+k1.*(mu1-T))))...
+(1./2.*b2).*((a2-b2.*mu2).^2-(a2-b2.*T).^2)+k0.*a2.*log(1+k1.*(mu2-T))-(b2./k1).*(T-mu2)+(b2./k1).*(T-(1./k1)).*log(1+k1.*(mu2-T)))));
disp('TC')
TC
disp(TC)
disp(vpa(TC))
disp('t1')
t1
disp(t1)
disp(vpa(t1))

Categories

Find more on Function Creation in Help Center and File Exchange

Products


Release

R2009b

Community Treasure Hunt

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

Start Hunting!