Class interval frequency

0-10 3

10-20 5

20-30 6

30-40 2

40-50 3

Then what is the procedure? I have simply taken the midpoints of the class interval as X and frequency as Y and calculated correlation coefficient between X and Y. Is it OK?

Please suggest.