Clear Filters
Clear Filters

How can I solve this problem in MATLAB? Warning!

2 views (last 30 days)
Hi everybody,
I am trying to solve a system of four equations with four unknown in matlab as below:
F = 96485
syms a b c d
When I run it, I get the following warning:
Warning: Unable to find explicit solution. For options, see help.
> In solve (line 317)
In four_Eqns (line 11)
ans =
0×1 empty double column vector
Can someone help me to fix this issue? I need to solve this system of 4 unknown equations.
Thank you very much

Accepted Answer

John D'Errico
John D'Errico on 21 Jan 2022
Edited: John D'Errico on 21 Jan 2022
That you need to solve it is not relevant. Does an analytical solution exist? Almost surely not. We all sometimes want for things we cannot have. Personally, I'm looking for world peace. Failing that, a Lamborghini would be nice. :)
struct with fields:
a: [0×1 sym]
b: [0×1 sym]
c: [0×1 sym]
d: [0×1 sym]
so the numerical solver failed to find any solution either.
Do you know a solution exists? How do you know that? One may exist, but you need to provide an intelligent set of starting values. That is difficult to know.
Do you need an exact solution to exist? Suppose you could find a solution that at least comes close to making each of those equations as close to zero as possible?
function val = obj(abcd)
F = 96485;
a = abcd(1);
b = abcd(2);
c = abcd(3);
d = abcd(4);
val = [-0.006882+(2*F*1.9499e-7*(0.034294*a*exp(b*-1.0337)+9.938e-9*c*exp(-1.0337*d)))/(1.9499e-7*9.938e-9+1.9499e-7*a*exp(b*-1.0337)+0.034292*c*exp(-1.0337*d));...
-0.005133+(2*F*3.1279e-7*(0.038873*a*exp(b*-1.0205)+1.1383e-8*c*exp(-1.0205*d)))/(3.1279e-7*1.138e-8+3.12793e-7*a*exp(b*-1.0205)+0.038873*c*exp(-1.0205*d)); ...
Given that, now I can use lsqnonlin.
abcd = lsqnonlin(@obj,rand(1,4))
Local minimum found.
Optimization completed because the size of the gradient is less than
the value of the optimality tolerance.
<stopping criteria details>
abcd =
0.28396 1.3469 1.3427 0.58855
ans =
Is it an exact solution? Of course not. In fact, a different set of random staritng values seems to find a different solution. That is no surprise, since a 4 dimensional space can be a big place to look.
I would point out though, since you have provided coefficients that are only accurate to about 4 digits, that a solution which comes roughly that close may be as good as you can hope to find.
  1 Comment
Torsten on 22 Jan 2022
@Mohiedin Bagheri comment moved here:
Thank you very much for your helpful answer. It really helped.

Sign in to comment.

More Answers (0)


Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!