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 Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by