matlab is taking too long to solve the equation.

1 次查看(过去 30 天)
while (FSt~=FSo)
FSo = FSt
Nu = W +(T.*sina)-(((p.*l.*sint) - (u.*l.*tanp.*sint))./FSo)
Nb = cost + (tanp.*sint)./FSo
N = Nu./Nb
up = sum((p*l*R)) + sum((N.*tanp*R)) - sum((u.*l*tanp*R))+sum(((FSo.*T*(R.*cosaw))))
down = sum(W.*xavg)
FSt = up/down %FOS after reinforcement%%
g=FSt-1
dp=diff(g,p);
p1=subs(dp,{p q r T},{C Gama Phi Tf});
p2=double(p1)
dq=diff(g,q);
q1=subs(dq,{p q r T},{C Gama Phi Tf});
q2=double(q1)
dr=diff(g,r);
r1=subs(dr,{p q r T},{C Gama Phi Tf});
r2=double(r1)
dT=diff(g,T);
T1=subs(dT,{p q r T},{C Gama Phi Tf});
T2=double(T1)
sums=double((p2*sig_tr_c)^2+(q2*sig_tr_gama)^2+(r2*sig_tr_phi)^2+(T2*sig_tr_T)^2)
c_prime= mu_tr_c-((p2*sig_tr_c)/sqrt(sums))*2*sig_tr_c;
gama_prime= mu_tr_gama-((q2*sig_tr_gama)/sqrt(sums))*2*sig_tr_gama; %here beta target =2
phi_prime = mu_tr_phi-((r2*sig_tr_phi)/sqrt(sums))*2*sig_tr_phi;
eq=subs(g,{p q r},{c_prime gama_prime phi_prime})
sol=vpasolve(eq==0,T)
end
end

回答(1 个)

Saurav Chaudhary
Saurav Chaudhary 2020-10-28
For this I would like to suggest running ''Profiler'' on your code as workaround.
To know more about profiling refer below points:
  • Profiling is a way to measure the time it takes to run your code and identify where MATLAB spends the most time.
  • After you identify which functions are consuming the most time, you can evaluate them for possible performance improvements.
  • You also can profile your code to determine which lines of code do not run.
You can refer this documentation link to see how to run profiler on your code-
You can also refer this link to look at some of the techniques that may help you improve performance-

类别

Help CenterFile Exchange 中查找有关 Manual Performance Optimization 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by