필터 지우기
필터 지우기

can anyone help me to solve this error?

조회 수: 3 (최근 30일)
ASWATHI V
ASWATHI V 2018년 5월 31일
댓글: ASWATHI V 2018년 5월 31일
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)

채택된 답변

Mridul G
Mridul G 2018년 5월 31일
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)));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by