finding lengths of an ellipse

조회 수: 7 (최근 30일)
PB
PB 2019년 4월 18일
댓글: David Wilson 2019년 4월 18일
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
David Wilson
David Wilson 2019년 4월 18일
See one of the many solutions, such as:
By the way, are you sure you have your parametric equation the right way around? It is typical to have it, that is the sine is connected to y, and the cosine with x. Nothing wrong with your specification, just unusual.
PB
PB 2019년 4월 18일
yes the parametric equations given this way and we have to MATLAB code for it.

댓글을 달려면 로그인하십시오.

채택된 답변

David Wilson
David Wilson 2019년 4월 18일
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
PB
PB 2019년 4월 18일
Thank you so much. How do add a small step size to this? justadd a step size in the linespace?
David Wilson
David Wilson 2019년 4월 18일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by