MATLAB: How to evaluate integral on a particular point using trapz

numerical integration

I extracted x and y data from a certain plot and now if there are 100 points in x and I want to evaluate an integral from x 0 to 60th point. How can I do it by using trapz. A brief section of my code is given below;
plot(xint,Sxint1(1,:));
h = findobj(gca,'Type','line');
x=get(h,'Xdata');
y=get(h,'Ydata');
Dx=trapz(x,cos(y));
Dy=trapz(x,sin(y));
Thanks in advance

Best Answer

trapz(x(1:61), cos(y(1:61)))