- Don't indcrease n to 20.
- Get a bigger, faster computer.
The solution process takes too long+vpasolve
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, I am solving a single variable nonlinear equation(i.e. eqn) using vpasolve. The solution speed is fine if n is equal to 10. However, it gets (kind of) stuck when I increase the n to 20. What is your recommendation?
*P.S. This code is a part of a major code in which C, l, beta, A, rho and... are all defined.
tol=0.001;
Error=100;
te=0;
EE=sym(zeros(n+1,1));
while Error>tol
syms x positive
for i=1:n+1
if i==1
EE(1,1)=0;
else
EE(i,1)=(((C*l(i-1)/x)+(((tan(phi*pi/180))/x)*((rho*9.81*A(i-1)*(cos(beta(i-1))))+(EE(i-1)*(sin(beta(i-1)-(te))))))-(rho*9.81*A(i-1)*(sin(beta(i-1))))+(EE(i-1)*(cos(beta(i-1)-(te)))))/((cos(beta(i-1)-(te)))+((sin(beta(i-1)-(te)))*(tan(phi*pi/180))/x)));
end
end
eqn = (simplify((EE(n+1,1))));
[k] =max(vpasolve(eqn, x ,[0.1 5]));
2 commentaires
John D'Errico
le 10 Juil 2020
Recommendation(s)?
As you increase n, at each iteration, each step uses the result from the previous step in the loop.
You don't tell us what all of those unknown constants are, so I cannot really do too much. But remember that EE is getting bigger, nastier, messier, at each and every step. So what do you expect?
Réponses (0)
Voir également
Catégories
En savoir plus sur Systems of Nonlinear Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!