MATLAB: The result generated from solve() is not a single value as I expected

solve

I am trying to solve for lamda in an equation that the sum of the probabilities of a Poisson random variable, P(X < 20), equals 0.05.
In my code, I uses a as lamda.
syms a
eqn = 0
for i = 0:19
eqn = eqn + exp(-a)*(a^i)/factorial(i)
end
eqn == 0.05
s = solve(eqn, a)
I was expecting s to be a single value, but instead I got this:
root(z^19 + 19*z^18 + 342*z^17 + 5814*z^16 + 93024*z^15 + 1395360*z^14 + ...
root(z^19 + 19*z^18 + 342*z^17 + 5814*z^16 + 93024*z^15 + 1395360*z^14...
...
the full output is not displayed here.
I wonder if anyone knows where my code is wrong. Thank you!

Best Answer

sol = vpasolve(eqn==0.5,a)
Your line
eqn == 0.5
does not have any useful effect: it just generates an equation and displays it and throws it away, but it does not affect your
s = solve(eqn, a)
line -- you are solving your eqn for equal to 0 rather than equal to 0.5