Effacer les filtres
Effacer les filtres

why converting to double takes forever?

1 vue (au cours des 30 derniers jours)
NooshinY
NooshinY le 22 Oct 2018
Hi I have this function, and I want to just calculate some intergrals. running the code without converting to double takes 1 minutes, but when I add Double(down) it takes for ever and I can't get an answer. Would anyone help me with this?
my code is:
function B=downtime(H12,H22,tau1)
syms u x y tau;
alpha1=2;
alpha2=3;
beta1=1.3;
beta2=1.5;
aa=0.000025;
mu1=0.5;
mu2=0.4;
sigma1=0.1;
sigma2=0.15;
muw1=1.2;
muw2=1;
sigmaw1=0.2;
sigmaw2=0.3;
D1=7.5;
D2=7;
a = 0.001841;
b = 0.004071;
m=3;
fu = a*u+b;
y11= normpdf(y,mu1,sigma1);
y12= normpdf(y,mu1*2,sigma1*2^0.5);
y13= normpdf(y,mu1*3,sigma1*3^0.5);
g=((x^(alpha1*tau-1))*exp(-x/beta1))/((beta1^(alpha1*tau))*gamma(alpha1*tau));
G1=int(g,x,0,H12-u);
G2=int(g,x,0,H12-u-y);
K1=int(G2*y11,y,0,H12-u);
K2=int(G2*y12,y,0,H12-u);
K3=int(G2*y13,y,0,H12-u);
R=int(G1*fu,u,0,H12)*exp(-aa*tau)+int(K1*fu,u,0,H12)*exp(-aa*tau)*(aa*tau)+int(K2*fu,u,0,H12)*exp(-aa*tau)*(aa*tau)^2/2+int(K3*fu,u,0,H12)*exp(-aa*tau)*(aa*tau)^3/6;
y21= normpdf(y,mu2,sigma2);
y22= normpdf(y,mu2*2,sigma2*2^0.5);
y23= normpdf(y,mu2*3,sigma2*3^0.5);
g2=((x^(alpha2*tau-1))*exp(-x/beta2))/((beta2^(alpha2*tau))*gamma(alpha2*tau));
G12=int(g2,x,0,H22-u);
G22=int(g2,x,0,H22-u-y);
K12=int(G22*y21,y,0,H22-u);
K22=int(G22*y22,y,0,H22-u);
K32=int(G22*y23,y,0,H22-u);
R2=int(G12*fu,u,0,H22)*exp(-aa*tau)+int(K12*fu,u,0,H22)*exp(-aa*tau)*(aa*tau)+int(K22*fu,u,0,H22)*exp(-aa*tau)*(aa*tau)^2/2+int(K32*fu,u,0,H22)*exp(-aa*tau)*(aa*tau)^3/6;
Rtotal=R*R2;
down=int(1-Rtotal,0,tau1);
down=double(down)
B=down;

Réponses (1)

NooshinY
NooshinY le 22 Oct 2018
for example you can run it for downtime(5,5,1) to see what is my problem. Thanks

Community Treasure Hunt

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

Start Hunting!

Translated by