How could I check my solution if I am doing a definite integration please?? I mean,since a definite integral is the limit of a sum so could I write a code using sum to check my results??

1 回表示 (過去 30 日間)
Avan Al-Saffar
Avan Al-Saffar 2014 年 10 月 27 日
回答済み: Torsten 2014 年 10 月 27 日
integral(f(x),a,b)=sum(f(xi),1,N)?

回答 (2 件)

Mischa Kim
Mischa Kim 2014 年 10 月 27 日
Avan, yes you could. For example:
f = @(x) sin(x);
a = 1;
b = 5;
N = 100;
f_int1 = integral(f,a,b)
f_int2 = sum(arrayfun(f,linspace(a,b,N)))*abs(b-a)/N
Try increasing N. Note that you need to sum up small rectangular areas of size f(x)*dx.

Torsten
Torsten 2014 年 10 月 27 日
I guess your question aims at the integration of the expression
f = @(T) ( A*(((N0*sin(omega*T).^2.*(1-2*P(T)./k))+(omega.*cos(omega*T) ) ).^2)./(N0.^2*sin (omega*T).^4.*(P(T)-P(T).^2./k).^2) )
from the other thread you opened.
Did you notice that the denominator of your above expression is zero at T=Pi and f thus becomes infinity at this point ?
Best wishes
Torsten.

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by