How to perform numerical integration of a vector in MATLAB?

I have a vector of 358 numbers. I would like to do a numerical integration of this vector, but I do not know the function of this.

I found that we can use trapz or quad, but I really don't understand how to integrate without a function.

+5
source share
3 answers

If you know the horizontal distance of your vector, you can use trapz to integrate it without a function. For example, to integrate y=sin(x)from 0 to pi with 358 partitions,

x=0:pi/357:pi;
y=sin(x);
area=trapz(x,y);

trapz(y), , , 1. x:

area=pi/357*trapz(y);
+8

; trapz quad. trapz . .

+7

, , . , . TRAPZ , , X . . , .

, , Wikipedia.

+2

All Articles