Value of trapz shrinking to zero
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
John D'Errico
il 1 Ago 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.
Risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!