MATLAB: Plot integral equation coming from ode solver

integrationMATLAB

I have an equation that comes from ode solver :
[t1 V1] = ode15s(dV1dt, t1, y1); plot(t1, V1 ,'-b','lineWidth',2)
then I do some basic addition or subtraction on it for eg :
Aout1=(V1-1); plot(t1,Aout1,'-b','lineWidth',2);
Now I wish to integrate the output : So I tried with
final = integral (Aout1, 0, 4.2)
But I get error :
Error using integral (line 82) First input argument must be a function handle.
I tried other things as well; but I don't achieve what I wish. Although 'cumsum' works well on it just like that.

Best Answer

Use the trapz (link) function:
idx = find(t1 <= 0.42);
final = trapz(t1(idx), Aout1(idx))
Since you menitoned cumsum, also see the documentation for cumtrapz (link).
Related Question