this is just a nonlinear equation for q. Thus it can be solved numerically with any derivative free rootfinding method, e.g. with the bisection method (the simplest choice) or with Brent's method. The latter is implemented in Matlab as fzero.m, see documentation .
Note that you can multiply the entire equation with q, then the second sum does not depend on q.
Hope this helps!