Please help! Am trying to find a
Show older comments
syms a
eqn = 5000 + 6800 - 10876 * ((1+a).^2-1)./(a(1+a)).^2 * 1./(1+a).^2 == 0;
sola = solve(eqn, a)
This is the error
Error using sym/subsindex (line 814)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and function body must be sym expression.

Answers (1)
Star Strider
on 5 Jul 2018
You are missing a multiplication operator. MATLAB does not recognise implied multiplication.
eqn = 5000 + 6800 - 10876 * ((1+a).^2-1)./(a(1+a)).^2 * 1./(1+a).^2 == 0;
↑ ← INSERT ‘*’ HERE
With that addition:
syms a
eqn = 5000 + 6800 - 10876 * ((1+a).^2-1)./(a*(1+a)).^2 * 1./(1+a).^2 == 0;
sola = solve(eqn, a)
produces:
sola =
root(z^5 + 4*z^4 + 6*z^3 + 4*z^2 + (231*z)/2950 - 2719/1475, z, 1)
root(z^5 + 4*z^4 + 6*z^3 + 4*z^2 + (231*z)/2950 - 2719/1475, z, 2)
root(z^5 + 4*z^4 + 6*z^3 + 4*z^2 + (231*z)/2950 - 2719/1475, z, 3)
root(z^5 + 4*z^4 + 6*z^3 + 4*z^2 + (231*z)/2950 - 2719/1475, z, 4)
root(z^5 + 4*z^4 + 6*z^3 + 4*z^2 + (231*z)/2950 - 2719/1475, z, 5)
However if you use vpasolve*:
sola = vpasolve(eqn, a)
the result is:
sola =
0.4782949577645820345467328553868
- 1.6314960838510317431154807318846 + 0.37168279788646925652089633009105i
- 1.6314960838510317431154807318846 - 0.37168279788646925652089633009105i
- 0.60765139503125927415788569580884 + 1.003620755351086792943582765314i
- 0.60765139503125927415788569580884 - 1.003620755351086792943582765314i
which is somewhat more informative.
Categories
Find more on Numeric Solvers in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!