0

I'm trying to use the symbolic math toolbox in Matlab 2012b to get symbolic solutions to a set of equations. My code looks like:

syms CPitch CRoll CYaw CX CY CZ
syms VPitch VRoll VZ
syms MPitch MRoll MZ

Eqs = [ MPitch == cos(VRoll)*CPitch + cos(CYaw)*VPitch;
        MRoll == cos(CYaw)*VRoll + sin(CYaw)*VPitch + CRoll;
        MZ == CZ*cos(VPitch)*sin(VRoll) + CY*sin(VPitch)*sin(VRoll) ];

solve(Eqs, {VRoll, VPitch, VZ})

I get back errors that look like:

Error in solve>tochar (line 289)
      vc = char(v);

Error in solve>getEqns (line 254)
  vc = tochar(v);

Error in solve (line 150)
[eqns,vars,options] = getEqns(varargin{:});

As far as I can tell everything matches how they do it in their examples. I'm not sure what it's complaining about.

ApockofFork
  • 487
  • 1
  • 4
  • 10
  • 1
    I'm not sure that you can specify a vector of symbolic equations as you do with `Eqs` (yes, annoying, and I've given The Mathworks feedback on this in the past). You could rewrite it as a single vector equation, I think, or just list them as separate equations. Also, I don't think that you can put your three variables (what you wish to solve for, I presume?) in a cell array either, but the docs for the Symbolic Toolbox have changed a lot over recent versions. – horchler Jul 02 '13 at 22:20
  • The example in the help documentation puts the equations in cell array and the variables you want to solve for in a vector. When I do it that way however it complains that cell elements must be character arrays. – ApockofFork Jul 03 '13 at 15:10
  • Which version of Matlab are you using? – horchler Jul 03 '13 at 15:12
  • I am using version 2012b.(updated post) – ApockofFork Jul 03 '13 at 15:36
  • I'm using the same version -I don't see where in the documentation/help such examples are given. Here's R2012b's [online doc for `solve`](http://mathworks.com/help/releases/R2012b/symbolic/solve.html), -identical to typing `doc solve` in the command window. Here's an example of [solving a system of equations](http://mathworks.com/help/releases/R2012b/symbolic/solve-a-system-of-algebraic-equations.html). Are you perhaps confusing outputs with inputs or maybe looking at the documentation for [MuPad's version of solve](http://mathworks.com/help/releases/R2012b/symbolic/mupad_ref/solve.html)? – horchler Jul 03 '13 at 15:56

0 Answers0