MATLAB: Find a variable as function of other variable with equations system using Symbolic ToolBox

symbolicSymbolic Math Toolbox

I have 3 equations that connects between 4 variables, let's say:
syms a b c d;
r=b+d;
e=pi/2;
eq1 = c - a*sin(d) + b*cos(d) == 0;
eq2 = r - c*tan(e) - a*cos(d) - b*sin(d) == 0;
eq3 = b == e*r + a*tan(e);
Now I would like to find c(d), means, I would like to find what is c as a function of other variable, in this case – d.
Then perform other operations on c(d) such as differntiate etc.
What would be the best/easiest way to do that using Symbolic Toolbox?
Thanks.

Best Answer

syms a b c d;
r = b+d;
e = sym(pi)/10; %not pi/2, that does not have a solution!
eq1 = c - a*sin(d) + b*cos(d) == 0;
eq2 = r - c*tan(e) - a*cos(d) - b*sin(d) == 0;
eq3 = b == e*r + a*tan(e);
sol = solve([eq1,eq2,eq3], [a, b, c], 'returnconditions', true);
c = symfun(simplify(sol.c), d);
This will be valid except at four sets of d values whose values can be deduced by analyzing sol.conditions (in each case adding an integer multiple of 2*pi gets another forbidden value)