let
n0 =
nx*cos(a) + nz*cos(b)*sin(a) + ny*sin(a)*sin(b)
ny*cos(b) - nz*sin(b)
nz*cos(a)*cos(b) - nx*sin(a) + ny*cos(a)*sin(b)
in a and b,with the ns fixed (but of course,not assigned) values. if I do
[a,b]=solve(n0-[1 0 0]',a,b,'IgnoreAnalyticConstraints',true)
i get
Error using solve>assignOutputs (line 257)
3 variables does not match 2 outputs.
Error in solve (line 193)
varargout = assignOutputs(nargout,sol,sym(vars));
then I wonder ''3 variables''? Then I try
>> [a,b,c]=solve(n0-[1 0 0]',a,b,'IgnoreAnalyticConstraints',true)
that's the response
a =
cos(a)/(cos(a)^2 + sin(a)^2)
b =
(sin(a)*sin(b))/((cos(a)^2 + sin(a)^2)*(cos(b)^2 + sin(b)^2))
c =
(cos(b)*sin(a))/((cos(a)^2 + sin(a)^2)*(cos(b)^2 + sin(b)^2))
what is it doing? what's in c? I suppose he's solving with respect to nx ny nz,but why?every time I try to solve a problem with n+k equation in n variables I get strange errors,even if the rank of the system is just n.
that means even a=2 b=3 a+b=5 gives me problems. how can I fix that?
I also cannot replicate the "Error in solve" error. What version of Matlab are you using? Also, I think some of the error message is missing – always list the entire error message. In any case, R2013a,
solvedoes not find any solutions. Mathematica 9'sSolvealso does not find any.I suspect why @DanielR and I can't exactly reduce your issue in the second case is that you may have a mistake in one of your lines above – it should be:
that produces
What are the outputs
a,b, andc(these simplify tocos(a),sin(a)*sin(b), andsin(a)*cos(b), by the way)? A big hint is that all of the solutions are in terms of your original variablesaandb, but notnx,ny, ornz. When you don't specify which variables to solve forsolvepicks them. If you instead return the solutions in structure form, the nature of the output is made clear:But I think that you probably want to solve for
aandbas a function ofnx,ny, andnz, not the other way around. You're not correct about usingsolveto find solutions to overdetermined systems. Even when you have more equations then unknowns this is not always possible with nonlinear equations. If you can introduce someassumptionsor even additional equations or specify numerical values for any of thenx,ny, ornzvariables,solvemay be able to separate and invert the equations.And you shouldn't really use the term "rank" except for linear systems. In the case of the linear system example that you gave
solveworks fine:or
or
returns