Can I trust the quad integration results with a warning of "minimum step size reached"?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have two different codes to calculate the integration. The first one uses int, the second one uses quad. The first one is calculated by int, and didn't give me any error message, so it should be the right answer. the second one give me warning ' Minimum step size reached; singularity possible.' and then give me a result, but diffent from the first one. so what does this warning mean? Does this warning mean I shouldnt trust its results when it appears? and why does the calculation reaches its minimum step size , I am quite confused with this process? if anybody can help, thank you very much.
the first code is:
for j=1:151
x(j)= -15+((j/150)*2*15);
syms y;
f =1- exp(-y^2/12.5);
a(j)=int('f',-x(j),3);
end;
a=a(:)
the second code is :
for j=1:151
x(j)= -15+((j/150)*2*15);
f =@(y) 1- exp(-y.^2/12.5);
a(j)=quadl(f,-x(j),3);
end;
a=vpa(a(:),4)
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 8 Okt. 2011
int('f',-x(j),3)
is going to return
f*(3+x(j))
except with the current value of x(j) substituted in.
int() is part of the symbolic toolbox, and it only operates on values that are passed as parameters or which have been imported via subs() or which have been assigned by MuPAD assignment statements.
You should instead be using
int(f, -x(j), 3)
I do not see anything obvious in the expression that should lead to a small step size for quadl()
Weitere Antworten (1)
Andrei Bobrov
am 8 Okt. 2011
Hi friends!
@Lin LI: use quad or quadgk:
a1 = arrayfun(@(j1) quad(@(x) 1- exp(-x.^2/12.5),15-j1/10*2,3), (1:151)')
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!