MATLAB: Equation solver solve() returns empty result

equation solver

I tried using symbolic equation solver to get the results
syms V a b K
eq1 = pi^2*(a+b).*(b-a).^2 == V
eq2 = V == 8000
eq3 = a == K*b
eq4 = K == 0.2:0.1:0.7
a = solve([eq1,eq2,eq3,eq4],a)
And I got
a =
Empty sym: 0-by-1
It should have solutions while it returned nothing. Did I have something wrong?

Best Answer

V = 8000;
Kvals = 0.2:0.1:0.7;
syms a b K
eq1 = pi^2*(a+b).*(b-a).^2 == V
eq3 = a == K*b;
sol = solve([eq1, eq3], [a, b]);
a = subs(sol.a, K, Kvals)
You will find that the result is 3 (different solutions) per K value. Two of the solutions are complex valued and the third is real valued.
Related Question