To find the length of a curve y=f(x), we can make use of the formula:
L =integral(sqrt(1+(dy/dx)^2));
Now you can make use of the functions "diff" and "int" in MATLAB to perform differentiation and integration operations.
As an alternative to "int" function, you can try using "quad" function also.
The following link is worth looking: https://www.mathworks.com/matlabcentral/newsreader/view_thread/20241
Hope this helps !