How do I solve a simple equation with symbolic variables?

1 view (last 30 days)
I currently have the following
syms k
%then after some steps of differentiation and substitution I get to
p=(k-3)/(k+2)
I want to find the value of k such that p=-1. How do I do this? My version of Matlab doesn't have the solve function but I am sure there must be a simpler way to work this out (edit: I was wrong - it does). Thanks!

Accepted Answer

Star Strider
Star Strider on 4 Aug 2015
There are likely many ways to do it.
One is:
syms k p
%then after some steps of differentiation and substitution I get to
p = -1;
Eqn = p == (k-3)/(k+2);
k = vpasolve(Eqn, k)
k =
0.5

More Answers (1)

Walter Roberson
Walter Roberson on 4 Aug 2015
Every version of the symbolic toolbox has supported solve() right back to the very first.
Not every version of the Symbolic Toolbox has supported using "=" or "==", so for those older versions if you have the expression A=B then you solve((A)-(B))

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!