Solving symbolic equation using solve
1 view (last 30 days)
Show older comments
Hi,
I am trying to minimize the value of phi here. I want the values of E for which phi becomes zero but the code is not providing any solution, also there is some problem in the execution of solve function.
Can someone please help with the proper function to be used here for minimization.
b = [(5/60) (10/60) ];
syms E xfun Ifun phi phidiff
xfun = sym(zeros(10,2));
Ifun = sym(zeros(10,2));
phi = sym(zeros(10,2));
phidiff = sym(zeros(10,1));
E_Vyas = zeros(10,1);
for prog = 1:1:2
for conv = 1:1:10
xfun(conv,prog) = -(E)./(8.314.*T(conv,prog)); %here T is temperature file(10 by 2 matrix)
Ifun(conv,prog) = (T(conv,prog).*exp(xfun(conv,prog)))-(Eiget(-xfun(conv,prog))./8.314);
end
end
for conv = 1:1:10
phi(conv) = (Ifun(conv,1).*b(2))./(Ifun(conv,2).*b(1)) + (Ifun(conv,2).*b(1))./(Ifun(conv,1).*b(2));
phidiff = diff(phi,E);
E_Vyas(conv) = (real(solve(phidiff,E)))/1000;
conv;
show = E_Vyas(conv);
end
E_Vyas = smooth(E_Vyas,0.1,'loess');
function [Eix] = Eiget(xfun) %function for approximation for I(E,T)
A = log((0.56146./xfun)+0.65).*(1+xfun);
B = (xfun.^4).*(exp(7.7*xfun)).*((2+xfun).^3.7);
Eix= (((A.^-7.7)+B).^-0.13)-((exp(-xfun))./xfun);
end
0 Comments
Accepted Answer
Walter Roberson
on 9 Feb 2021
b = [(5/60) (10/60) ];
syms E xfun Ifun phi phidiff
xfun = sym(zeros(10,2));
Ifun = sym(zeros(10,2));
phi = sym(zeros(10,1));
phidiff = sym(zeros(10,1));
E_Vyas = zeros(10,1);
for prog = 1:1:2
for conv = 1:1:10
xfun(conv,prog) = -(E)./(8.314.*T(conv,prog)); %here T is temperature file(10 by 2 matrix)
Ifun(conv,prog) = (T(conv,prog).*exp(xfun(conv,prog)))-(Eiget(-xfun(conv,prog))./8.314);
end
end
guess = sym('1.0');
for conv = 1:1:10
phi(conv) = (Ifun(conv,1).*b(2))./(Ifun(conv,2).*b(1)) + (Ifun(conv,2).*b(1))./(Ifun(conv,1).*b(2));
phidiff(conv) = diff(phi(conv),E);
tic
sol = vpasolve(phidiff(conv),E,guess);
toc
if isempty(sol)
E_Vyas(conv) = nan;
else
E_Vyas(conv) = real(sol)/1000;
guess = sol;
end
end
E_Vyas_smooth = smooth(E_Vyas,0.1,'loess');
function [Eix] = Eiget(xfun) %function for approximation for I(E,T)
A = log((0.56146./xfun)+0.65).*(1+xfun);
B = (xfun.^4).*(exp(7.7*xfun)).*((2+xfun).^3.7);
Eix= (((A.^-7.7)+B).^-0.13)-((exp(-xfun))./xfun);
end
More Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!