필터 지우기
필터 지우기

How to evaluate multiple definite integrals using the integral(F,min,max) function?

조회 수: 6 (최근 30일)
I am trying to evaluate the integral of a function F using the integral(F,min,max) Matlab built-in function. The problem is that I want to evaluate the integral for a range of definition intervals (xmin,xmax), not just for one pair of values, and I get the "A and B must be floating point scalars" error message. I attached the code below:
% F(d) function definition
format long;
d = [1e-6:1e-7:1e-5];
F = (1./4)*(pi*pi*4e-7*(1.3e5)^2*(0.5e-6)^4)*(1./d.^2+1./(d+2*(0.67e-6)).^2-2./(d+(0.67e-6)).^2);
% F(d) plot
plot(d,F,'green', 'LineWidth', 2);
% Definite integral evaluation
F = @(d)(1./4)*(pi*mu0*M^2*R^4)*(1./d.^2+1./(d+2*H).^2-2./(d+H).^2);
dmin = [1e-6:1e-7:1e-5];
dmax = [1e-6+1e-7:1e-7:1e-5+1e-7];
L = integral(F,dmin,dmax)
What should I do in order to calculate the values of my definite integral for all the definition intervals ((1e-6, 1.1e-6), (1.1e-6,1.2e-6),..., (1e-5,1.01e-5))?

채택된 답변

Mike Hosea
Mike Hosea 2012년 9월 25일
L = arrayfun(@(a,b)integral(F,a,b),dmin,dmax)

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by