finding lengths of an ellipse

9 views (last 30 days)
PB
PB on 18 Apr 2019
Commented: David Wilson on 18 Apr 2019
I have to find the lengths of an ellipse which is given by y = cost and x = 5 sint. Evaluate the length from t1=0 to the following points,
t2=[0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6]. Have to use one of the methods, trapezoidal, midpoint or simpson's to two digit accuracy. How do i write a script from 0 to 0.5, 0 to 1, 0 to 1.5 etc ( from 0 to each point) to get 12 values for the lengths.
  2 Comments
PB
PB on 18 Apr 2019
yes the parametric equations given this way and we have to MATLAB code for it.

Sign in to comment.

Accepted Answer

David Wilson
David Wilson on 18 Apr 2019
If you need a little more help, then it pays to plot the ellipse and look at the arc lengths.
t = linspace(0,2*pi)';
x = @(t) 5*sin(t); y = @(t) cos(t);
t2=[0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6]';
plot(x(t),y(t),'r-', ...
x(0), y(0), 'bs', ...
x(t2), y(t2), 'kh');
for i=1:length(t2)
text(x(t2(i)), y(t2(i)),sprintf('%2.1f',t2(i)))
end
grid on; axis equal;
xlabel('x'); ylabel('y')
tmp.png
It's important to have the axis equal in order to roughly approximate the arc lengths. You can see that from t=0 to t=0.5, the arc length is a little over 2.5. That makes a good check.
Now I've used the formlar above for the arc length, but I've had to convert your sine to my cosine etc. I;'ve also used integral, your (homework?) requested you use a simpler Simpson etc, which I'll leave you to implement. At least you have a tentative solution.
>> f = @(t) sqrt(25*sin(pi/2-t).^2 + cos(pi/2-t).^2);
>> arcLengths = arrayfun(@(t2) integral(f,0,t2), t2)
arcLengths =
2.4014
4.2454
5.1803
5.8983
7.5035
9.7993
12.2605
14.3121
15.5117
16.1217
17.4652
19.6122
As a check, you can see that my guess of 2.5 is not too far off.
  2 Comments
David Wilson
David Wilson on 18 Apr 2019
Following my way, you don't need to adjust the stepsize since integral will (magically) take care of it using its adaptive step size ability. I didn't bother add any tolerance to integral, since 2 decimal places is pretty lax.
HOWEVER, you were asked to use a simple integrator without error control, so you will have to choose a suitable stepsize when using Simpson's etc. If you are going to use a straight-forward approach, I'd subdivied the interval (in t) to say about 100 steps as a first approximation.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!