What is the difference between int and integral.

조회 수: 81 (최근 30일)
Ashwani Kumar MAlviya
Ashwani Kumar MAlviya 2020년 5월 9일
편집: Torsten 2022년 12월 10일
Hello everyone
I want to get explained how to decide wheather use function "int" or "integral".
What is the basic difference between them? will they give same answer for a given function?
Thank you very much in advance.
  댓글 수: 1
Ashwani Kumar MAlviya
Ashwani Kumar MAlviya 2020년 5월 9일
n = length(FC); % Calculates the Number of consistant respondents(Nt)
x = sum(FC == mode(FC)); % Calculates the Number of respondents answered mode
p = 1/17; % Probability of selecting mode(Pi)
mu = n*p;
sigma = sqrt(n.*p.*(1 - p)); % Standerd deviation
if n<= 20
i = 0;
syms i
alfa = double(symsum((factorial(n)/(factorial(i)*factorial(n-i))*(p).^(i)*(1-p).^(n-i)), i, 0, x)); % 0 = constant, 2 = x
% beta1 = symsum((factorial(n)/(factorial(i)*factorial(n-i))*(1-1/17).^(i)*(1/17).^(n-i)), i, 0, n-x);
% power = 1-beta1;
elseif n>20
syms y
f = (-(y-mu)^2)/(2*sigma^2); % 5.05 is 2*sigma^2, & 2.7 = mu
fun = (1/(sigma*2.5))*(exp(f)); % 0.2516 = 1/(sigma*2.5), e = 2.71
a = -inf;
b = x; %x; % number of respondent selected mode
alfa = double(int(fun, a, b));
%%% ^ if I am using integral here, I am getting different answer. what mistake am I making conceptually.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2020년 5월 9일
The int function integrates symbolic expressions (or does its best, consdidering that not all expressions have analytic integrals).
The integral function is for numeric functions, usually anonymous functions.
The documentation pages for those functions explain them better than I can, so I provided links to them.
  댓글 수: 4
Temi
Temi 2022년 12월 10일
Hello @Star Strider!!! when evaluating definite integrals using int, what integration scheme does the function use? trapezoid, rungekutta, quadrature, simpsons?
which is better to evaluate integrals numerically?; int or integral
Torsten
Torsten 2022년 12월 10일
편집: Torsten 2022년 12월 10일
"int" tries to find an analytical antiderivative of your function. So it does not use any numerical integration scheme.
For the integration method of "integral", see
[1] L.F. Shampine “Vectorized Adaptive Quadrature in MATLAB®,” Journal of Computational and Applied Mathematics, 211, 2008, pp.131–140.
If the function does not look too complicated, try "int" first.
If no analytical antiderivative can be found using "int", use "integral".

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by