- Don't indcrease n to 20.
- Get a bigger, faster computer.
The solution process takes too long+vpasolve
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
John D'Errico
2020 年 7 月 10 日
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?
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Systems of Nonlinear Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!