What is the difference between int and integral.

83 次查看(过去 30 天)
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
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