ode45 versus quad/quadv/trapz
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have to compute the average of a given parameter, i.e. I have to solve an equation of the type
average_y(x) = A * integral( x^a * y * dx)
where a and A are constants and, as shown, y is a function of x. This equation can be written in the form
d/dx (average_y(x)) = A * x^a * y
What form can be better solved with Matlab? Should I use the first form (with trapz or quad for example)? Or the second form with an ode-function (like ode45)? Please tell me what function you would use regarding the method you choose.
Thanks for your help.
Tibo
0 Kommentare
Akzeptierte Antwort
John D'Errico
am 11 Mär. 2011
Well, since you can't set a tolerance with trapz, the difference seems pretty clear there.
And if all you want is the final result, then why bother with an ode solver that will waste time in generating the intermediate results too?
So use the proper tool for the job. If you want to do numerical integration to compute an overall integral, as accurately as possible, use a tool designed to do just that. I have found quadgk to be more efficient and more robust than quad usually.
Weitere Antworten (1)
Anatoliy
am 13 Jun. 2011
I can't build lagrangepoly and newtonpoly using "spline" X = [0.13 0.18 0.23 0.28 0.33 0.38]; Y = [0.129 0.179 0.228 0.276 0.324 0.371];
1 Kommentar
John D'Errico
am 14 Jun. 2011
What does this answer have to do with the question? And, what is your question anyway? I have a hard time making apples from oranges anyway.
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!