MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by Hugh Kriger
on 19 Nov 2012

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?

Answer by Walter Roberson
on 19 Nov 2012

Accepted answer

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.)

Hugh Kriger
on 19 Nov 2012

Thank you very much for your answer Walter. Does that mean if I wait long enough the MATLAB will solve the system or it will wait forever?

Is there a way you can suggest to overcome that memory problem?

## 0 Comments