can anyone help me to solve this error?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
lamda_b1 = 1;
lamda_r1 = 0.5;
lamda_r2 = 0.5;
lamda_br = 0.5;
lamda_rr = 0.3;
a_1 = 0.05;
a_2 = 0.95;
k_1 = (0.1).^2;
k_2 = (0.08).^2;
row_s1 = 5;
row_s = (10./row_s1)^10;
row_r = row_s./2;
a = @(x) (x./(lamda_r2.*row_r));
b = @(x) (x./(a_2-(a_1.*x)));
c = (1./(lamda_br.*row_s));
d = (1./(lamda_b1.*row_s));
f = @(x) exp(-a(x)-(b(x).*(c(x)+d(x))));
g = @(x) 1./(1+((k_2.*lamda_rr.*row_r.*x)./((a_2-(a_1.*x)).*lamda_br.*row_s)));
h = @(x) 1./(1+((k_1.*lamda_r1.*row_r.*x)./((a_2-(a_1.*x)).*lamda_b1.*row_s)));
i = @(x) (1./(1+x));
fun = @(x) f(x).*g(x).*h(x).*i(x);
q = integral(fun,0,Inf)
error----------------------------------
Subscript indices must either be real positive integers or logicals.
Error in @(x)exp(-a(x)-(b(x).*(c(x)+d(x))))
Error in @(x)f(x).*g(x).*h(x).*i(x)
Error in integralCalc/iterateScalarValued (line 314) fx = FUN(t);
Error in integralCalc/vadapt (line 132) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 83) [q,errbnd] = vadapt(@AToInfInvTransform,interval);
Error in integral (line 88) Q = integralCalc(fun,a,b,opstruct);
Error in test_1 (line 27) q = integral(fun,0,Inf)
0 Commenti
Risposta accettata
Mridul G
il 31 Mag 2018
The problem lies in the function f
f = @(x) exp(-a(x)-(b(x).*(c(x)+d(x))));
You have declared c and d as scalar variables however you are accessing them as vector in your function f. Changing it to the below fixed your error.
f = @(x) exp(-a(x)-(b(x).*(c+d)));
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Computations in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!