Value of trapz shrinking to zero
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Allan Andre do Nascimento
am 1 Aug. 2016
Kommentiert: Allan Andre do Nascimento
am 1 Aug. 2016
Dear Matlab community,
I am calculating an index with trapz and I am having some strange results. This index gets a solution from an ode and makes use of trapz. The strange thing is that depending on the number of points generated by the ode, the trapz value decreases indefinetly (the bigger the number of points the smaller the value of trapz). A decrease could be expected if the trapezoids approximating the function were "bigger" that the real functon, but as the number of points increased, trapz value should approximate a fixed value (which is the real value of trapz). Furthermore trapz is calculating the area based only on positive numbers, thus the area should not go to zero.... Could someone please help me with that?
6 Kommentare
John D'Errico
am 1 Aug. 2016
This is always the best way to solve a problem - by thinking it out, making a conjecture about the problem. When I have a problem like this, once I have some conjecture as to the reason, there is usually a way I can test the validity of my conjecture.
For example, use a finer interval. Or use a better interpolant. The default for interp1 is a piecewise linear interpolation. However you can also use various spline options for interp1, which will generally yield a higher accuracy to approximate a smooth function.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!