MATLAB: Unknown variable within an equation

dawsonSymbolic Math Toolbox

Hello,
I have an equation of the form P*dawson(sqrt(log(P)-log(A)))== sqrt(B)*T to be solved.
Variable A and B are scalar, but variable T is a vector. I need to solve for P in the equation.
This is the code I have written
syms P
T=5:5:500;
A=2;
B=0.5;
eqn = P*dawson(sqrt(log(P)-log(A)))== sqrt(B).*T ;
s = solve(eqn,P)
s =
Empty sym: 0-by-1
That is the solution for s I got.
Please advise what can be done.
Thanks.

Best Answer

Try this:
syms P T
A=2;
B=0.5;
eqn = P*dawson(sqrt(log(P)-log(A))) - sqrt(B).*T ; % Rearrange
eqnfcn = matlabFunction(eqn, 'Vars',{P,T}) % Anonymous Function
T=5:5:500;
for k1 = 1:numel(T)
Pv(k1) = fsolve(@(P)eqnfcn(P,T(k1)), 10);
end
figure
plot(T, Pv)
grid
xlabel('T')
ylabel('P')