Matlab 2012b too slow when solving a system of two equations on mupadmex(statement)
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm trying to solve a system of two non-linear equations in Matlab in a for loop. I am aware that the for loop may cause the program to run slow but right now it takes around an hour for one instance to be solved. On debugging the code, I realized that this line causes the program to hang:
[res,status] = mupadmex(statement);
If I terminate the program I get the following:
Operation terminated by user during mupadengine/evalin (line 97)
In mupadengine/feval (line 150) [S,err] = evalin(engine,stmt);
In solve (line 160) sol = eng.feval('symobj::solvefull',eqns,vars);
In algorithm2 (line 139) answer = solve (f , g);
where line 97 refers to the same line of code. Here's the section of my code where I call the solve function:
if true
% code
endsyms ro1 t_prime1
assume(t_prime1 > 0)
for i=1:1:length(n1ps)
n1p = n1ps(1,i);
n2p = n2ps(1,i);
w1 = (ro1/theta_p)*(1-exp((-1)*theta_p*t_prime1));
w2 = exp((-1)*theta_p*t_prime1);
w3 = (ro1/theta_p)*(1-exp((-1)*theta_p*T1))-q(1,1);
w4 = (1-exp((-1)*n1p*theta_p*T1))/(1-exp((-1)*theta_p*T1));
w5 = exp((-1)*theta_p*(T1-t_prime1));
Q1 = (w1 + w2*w3*w4)*w5 - q(1,1);
w6 = ((ro-ro1)/theta_p)*(1-exp((-1)*theta_p*(n1p*T1 + t_prime1 - n2p*T2)));
w7 = exp((-1)*theta_p*(n1p*T1 + t_prime1 - n2p*T2));
w8 = ((ro-ro1)/theta_p)*(1-exp((-1)*theta_p*T2))-q(1,2);
w9 = (1-exp((-1)*n2p*theta_p*T2))/(1-exp((-1)*theta_p*T2));
w10 = exp((-1)*theta_p*(T2-(n1p*T1 + t_prime1 - n2p*T2)));
Q2 = (w6 + w7*w8*w9)*w10 - q(1,2);
Q1_prime = q(1,1)*((exp((tN1 - n1p - 1)*theta_p*T1)-1)/(1-exp((-1)*theta_p*T1)));
Q2_prime = q(1,2)*((exp((tN2 - n2p - 1)*theta_p*T2)-1)/(1-exp((-1)*theta_p*T2)));
f=Q1_prime-Q1;
g=Q2_prime-Q2;
answer = solve (f , g);
end
0 comentarios
Respuestas (1)
Stefan Wehmeier
el 30 de Oct. de 2014
A running time of one hour can be normal if the equations are very complicated. Since your code does not run as it stands, it is difficult to comment on this. General comment: by your assumption, you do not help the solver since it has to determine which of the solutions are positive. Try the option 'IgnoreProperties' to skip this step.
0 comentarios
Ver también
Categorías
Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!