Warning: Unable to solve symbolically. Returning a numeric solution using vpasolve.
how to solve the below transcendental equation for the given data?
이전 댓글 표시
format compact
syms T t0
lambda=600; b=3;
theta=0.02;
c=5;
k=250;
h=1.75;
p=50;
M=.12;
Id=0.003;
TC=(k/T)+(c*lambda)+((lambda*(c*theta+h)*(exp(theta*t0)-theta*t0-1))/(T*(theta)^2))+((lambda*b*(T-t0)^2)/(2*T))+((lambda*p*M^2*Id)/(2*T));
dTCdt0=diff(TC,t0);
dTCdT=diff(TC,T);
[T,t0]=solve(dTCdt0,dTCdT)
t0=subs(t0);
digits(3)
t0=vpa(t0)
T=subs(T);
T=vpa(T)
TC=subs(TC);
digits(3)
TC=vpa(TC);
TC=round(TC)
%z=sqrt((2*k*(h+c*theta)*b)/(b+h+(c*theta)))*(sqrt(3800)-137.816)
댓글 수: 3
M.Rameswari Sudha
2024년 4월 9일
Manikanta Aditya
2024년 4월 9일
The issue you're facing with the code not working consistently is likely due to the symbolic engine being reset or cleared between runs. This can happen if you're running the code in different sessions or if some other operation clears the symbolic engine's state.
To ensure consistent behavior, you could try encapsulating the entire code in a function and calling that function each time you want to execute it. This way, the symbolic engine's state is reset at the beginning of each function call.
Here's an example of how you could structure the code as a function:
function [T, t0, TC] = solve_transcendental_equation()
syms T t0
lambda = 600; b = 3;
theta = 0.02;
c = 5;
k = 250;
h = 1.75;
p = 50;
M = 0.12;
Id = 0.003;
TC = (k/T) + (c*lambda) + ((lambda*(c*theta+h)*(exp(theta*t0)-theta*t0-1))/(T*(theta)^2)) + ((lambda*b*(T-t0)^2)/(2*T)) + ((lambda*p*M^2*Id)/(2*T));
dTCdt0 = diff(TC, t0);
dTCdT = diff(TC, T);
[T_sol, t0_sol] = vpasolve(dTCdt0, dTCdT, [T, t0]);
T = double(T_sol);
t0 = double(t0_sol);
TC = subs(TC);
digits(3);
TC = vpa(TC);
TC = round(TC);
end
You can then call this function as many times as you need, and it should provide consistent results:
[T, t0, TC] = solve_transcendental_equation()
I hope this helps, if this helps, let me know I will post as answer, you can accept it to make it more helpful.
M.Rameswari Sudha
2024년 4월 9일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!