Reputation: 774
While trying to solve a system of equations with 2 variables and 2 unknowns (Izhikevich nullclines), I encountered an unexpected error: Warning: 4 equations in 2 variables.
and Warning: Explicit solution could not be found.
This is unexpected because as I stated, I was providing only 2 equations with the 2 variables, which should be a well-formed system of equations.
My relevant lines of code are as follows:
syms uu vv
[solvv, soluu] = solve([0.04*vv^2 + 5*vv + 140 - uu + I(t) == 0, a(t)*(b(t)*vv - uu) == 0], [vv, uu]);
The complete error trace is:
Warning: 4 equations in 2 variables.
\> In C:\Program Files\MATLAB\R2012b\toolbox\symbolic\symbolic\symengine.p>symengine at 54
In mupadengine.mupadengine>mupadengine.evalin at 97
In mupadengine.mupadengine>mupadengine.feval at 150
In solve at 160
In Q3_new at 37
In run at 64
Warning: Explicit solution could not be found.
\> In solve at 169
In Q3_new at 37
In run at 64
Confused, I went to MATLAB's documentation for solve
and tried using the example snippet for solving a multivariate system of equations:
syms u v
[solv, solu] = solve([2*u^2 + v^2 == 0, u - v == 1], [v, u])
The expected output of this snippet, according to the documentation, is:
solv =
- (2^(1/2)*1i)/3 - 2/3
(2^(1/2)*1i)/3 - 2/3
solu =
1/3 - (2^(1/2)*1i)/3
(2^(1/2)*1i)/3 + 1/3
but the snippit instead returns:
Warning: 4 equations in 2 variables.
\> In C:\Program Files\MATLAB\R2012b\toolbox\symbolic\symbolic\symengine.p>symengine at 54
In mupadengine.mupadengine>mupadengine.evalin at 97
In mupadengine.mupadengine>mupadengine.feval at 150
In solve at 160
Warning: Explicit solution could not be found.
\> In solve at 169
solv =
[ empty sym ]
solu =
[]
as before.
Now I know I'm not making some beginner's mistake with my code because even the example code errors in the same way. Calling the singlevariate example snippit works as expected. I have tried this with MATLAB 2012a and MATLAB 2014a.
What could explain this unusual behaviour?
Upvotes: 1
Views: 2336
Reputation: 1210
Can duplicate this on MATLAB 2014a. I found that if I already defined the variables using syms
you can let solve
resolve the variables automatically.
syms u v
[sv, su] = solve([2*u^2 + v^2 == 0, u - v == 1], [v, u]) % Doesn't work
% works but order-unspecified so this is not desirable
[su, sv] = solve([2*u^2 + v^2 == 0, u - v == 1])
Another user points out a mistake in using the incorrect documentation. MATLAB 2014a uses the following notation instead for re-ordered solutions. The other form seems to be for 2015. You should probably verify this holds true in 2012a but it seems to do so
syms u v
[sv, su] = solve([2*u^2 + v^2 == 0, u - v == 1], v, u)
Upvotes: 3