plot the integral of an array

9 次查看(过去 30 天)
Jeroen
Jeroen 2014-3-6
编辑: Patrik Ek 2014-3-6
Okey, I've been stuck with this problem for a couple of days now so I'm just going to ask for help here.
I've got an array with `n' numbers f=[1,n]. I can plot this array and it gives me a nice graph. Now I want to integrate this graph. I'm not interested in the total area underneath the graph, but I want to plot the integral.
Analytically this means that I have a function (f), want to find it's integral and then plot the integral (F). The problem is that in this case I don't have the function, only a set of coordinates. I already know that the function f can be approached with an interpolation between the known points.
Thanks in advance.

回答(1 个)

Patrik Ek
Patrik Ek 2014-3-6
编辑:Patrik Ek 2014-3-6
Ok if it is not too important that the integral is completely correct I guess that "cumsum" would work. Otherwise, you may want to create an own trapz, simps, or whatever method you like, that returns each element. Remember that you can also use any runge kutta method for solving numerical intgrals.

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by