Calculating CL and CD from Cp vs. x/c graph data? I need to calculate CL, CD, CM coefficients for NACA 0012 airfoil at angle of attack 6 degrees and Re=7.5e5, Mach=0.05. I used Xfoil for getting the CP distribution, Cp vs. x/c graph and Cp-x-y data. With Cp-x and Cp-y data points I tried to calculate CL and CD values with a matlab code with equations given below;

I integrate the CP-x, CP-y points which executed with XFoil respectively to getting Cx and Cy. I used trapz command in matlab to integrate these points. However at the end of my calculation matlab code was found that CL=1.1936e-04 and CD=0.7249. However at the graph screen of XFoil CL and CD was different.

I can not understand that if the problem was about my solution method or my matlab code? How can I get the  coefficients with Cp distribution?
You have done it correctly. Only mistake appears to be swapping the CL and CD value.
Being said that, for the info, this CD mearly is a numerical error due to ds being finite as invisvid flow drag is zero.