MATLAB: Warning: Cannot solve symbolically

symbolicwarning

I'm writing up a code to calculate the angle of elevation of a cannon when given a range and an initial velocity. I will run the below function and get the correct answer, but I will also receive a warning message saying:
Warning: Cannot solve symbolically. Returning a numeric approximation instead. > In solve (line 304) In projectileaim (line 27)
How do I get rid of this pesky message once and for all?
function [ ] = projectileaim( v,range )
% Inputs: v - initial velocity (m/s)
% range - range of the target
% Outputs: plot of projectile
format long
k = 0.32;
m = 3;
c = m*k; %simplified constant to find terminal velocity
v_t = (m*9.81)/c; %terminal velocity
syms t theta
theta2 = acos((9.81*range)/(v*v_t*(1-exp(-9.81*t/v_t))));
eqn = [0 ==((v_t)/(9.81))*(v*sin(theta2) + v_t)*(1-exp(-9.81*t/v_t))-t*v_t];
vars = [t];
time = solve(eqn,vars);
eqn2 = [theta == acos((9.81*range)/(v*v_t*(1-exp(-9.81*time/v_t))))];
vars2 = [theta];
theta_final = solve(eqn2,vars2);
objfunc = acos((9.81*range)/(v*v_t*(1-exp(-9.81*time/v_t)))) - theta_final;
if isreal(time) == 0 && isreal(theta_final) == 0
error('Target is out of range!');
else
fprintf('Target acquired at %.2f meters downrange; adjust angle to %.5f radians and prepare to fire!\n',abs(range),theta_final);
end
projectiledrag(m,k,v,theta_final);
end

Best Answer

Use vpasolve instead of solve