MATLAB "solve" function not giving results and getting into infinite loop?
6 views (last 30 days)
Show older comments
Hugh Kriger
on 19 Nov 2012
Commented: Walter Roberson
on 11 May 2016
I am using MATLAB's "solve" function to solve 4 equations for 4 unknowns. The equations are very complex but I am pretty sure that there is a solution for that system of equations. When I try to do that, MATLAB just gets stuck and not give any output. It is like MATLAB will be running forever.
My code basically looks like below:
PE = f(C1,C2,C3,C0);
%take derivatives of potential energy
dPE_C1 = diff(PE,C1,1);
dPE_C2 = diff(PE,C2,1);
dPE_C3 = diff(PE,C3,1);
dPE_C0 = diff(PE,C0,1);
%solve the systems of equations
Sbeam = solve(dPE_C1,dPE_C2,dPE_C3,dPE_C0,C1,C2,C3,C0);
Sbeam = [Sbeam.C1 Sbeam.C2 Sbeam.C3 Sbeam.C0];
c1 = Sbeam(1);
c2 = Sbeam(2);
c3 = Sbeam(3);
c0 = Sbeam(4);
I need to find the values of C1,C2,C3 and C0 but the MATLAB got stuck.
Have you ever experienced any problems like that? Do you have any suggestions how to solve it?
0 Comments
Accepted Answer
Walter Roberson
on 19 Nov 2012
Even just solving four equations in four unknowns can take quite large amounts of memory. For example there was a recent post involving four equations that had ^2 in some of the terms; when I tried to solve on my system, I had to terminate it after it has gone through 6 gigabytes of memory. As soon as you get something that needs to work with explicit roots of a quartic, you are probably going to run out of memory (at least up to 8 Gb.)
3 Comments
Bram Delfos
on 11 May 2016
Hee Hugh,
I have exactly the same issue... Did you find a solution? Or is the only answer a better computer?
Cheers, Bram
Walter Roberson
on 11 May 2016
The solution is often to work iteratively, eliminating variables, taking one branch at a time and pursuing it. But sometimes there is just no practical approach to eliminate even the first variable when equations are sufficiently complex. For example the Three Body Problem does not involve many variables but there is no solution known.
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!