integral calculation size problem

조회 수: 1 (최근 30일)
Xuejian Niu
Xuejian Niu 2022년 2월 4일
답변: Steven Lord 2022년 2월 4일
a = 0.6;
% Define pu and pL
PU = 130000*exp(-x./(10*a));
PL = 150000*exp(-x./(10*a));
% integral cal
fun1 = @(x) (PL - PU);
N1 = integral(fun1,0,3*a);
% the matlab shows me a error here (output of function must be same size as input)
% Actually, I am not show where the error is, could you help me to fix it?

답변 (2개)

Arif Hoq
Arif Hoq 2022년 2월 4일
편집: Arif Hoq 2022년 2월 4일
i took the value of x=10, because you did not mention that. you need to mention ArrayValue as true, cause you are using the function as array/vector value
a = 0.6;
x=10;
% Define pu and pL
PU = 130000*exp(-x./(10*a));
PL = 150000*exp(-x./(10*a));
% integral cal
fun1 = @(x) (PL - PU);
N1 = integral(fun1,0,3*a,'ArrayValued', true)
N1 = 6.7995e+03

Steven Lord
Steven Lord 2022년 2월 4일
a = 0.6;
% Define pu and pL
Make PU and PL functions of x.
PU = @(x) 130000*exp(-x./(10*a));
PL = @(x) 150000*exp(-x./(10*a));
% integral cal
Call those functions in your integrand.
fun1 = @(x) (PL(x) - PU(x));
N1 = integral(fun1,0,3*a)
N1 = 3.1102e+04

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by