Question: In MatLab Write a function that computes the approximate perimeter an ellipse using the perimeters of inner and outer polygons (see Section 5.2). You may
In MatLab



Write a function that computes the approximate perimeter an ellipse using the perimeters of inner and outer polygons (see Section 5.2). You may include the function PolyLine developed in the previous problem as a local function. Your function should not contain any loops. Your Function C Reset B MATLAB Documentation 1 function [P, relErrEst]-P_ave(a, b,n) 2 %p AVE approximates the perimeter of an ellipse with semi axes a and b, 3 %using the perimeters of inner and outer polygons with n sides 4 is the average of perimeters of inner and outer polygons 5 %relErrEst stores the relative error bound 7 theta 2*pi 8 thetaketheta"(1:n); % generates a vector of k*theta for k=1:n 10 pyk= . . . 11 amma. % generate vectors of vertex coordinates for the inner polygon (see Eq 5.3) 13 Qykz %generate vectors of vertex coordinates for the outer polygon (see Eq 5.4) 14 P-inner-... % use POIy Line to compute the perimeter of inner and outer polygons 15 P-outer-... % make sure each input vector has n+1 elements 16 P (Pinner+P_outer)/2; 17 relErrEst-abs(P-inner-p-outer)/(2*P); %relative error bound 18 19 end 21 function L PolyLine(u,v) v(n+1) u and v are (n+1)-vectors with u(1)-u(n+1) and v(1) 23 %L is the perimeter of the polygon with vertices 24 %(u(1),V(1), (u(2),V(2)), , (u(n) 26 %function body of polyLine end Write a function that computes the approximate perimeter an ellipse using the perimeters of inner and outer polygons (see Section 5.2). You may include the function PolyLine developed in the previous problem as a local function. Your function should not contain any loops. Your Function C Reset B MATLAB Documentation 1 function [P, relErrEst]-P_ave(a, b,n) 2 %p AVE approximates the perimeter of an ellipse with semi axes a and b, 3 %using the perimeters of inner and outer polygons with n sides 4 is the average of perimeters of inner and outer polygons 5 %relErrEst stores the relative error bound 7 theta 2*pi 8 thetaketheta"(1:n); % generates a vector of k*theta for k=1:n 10 pyk= . . . 11 amma. % generate vectors of vertex coordinates for the inner polygon (see Eq 5.3) 13 Qykz %generate vectors of vertex coordinates for the outer polygon (see Eq 5.4) 14 P-inner-... % use POIy Line to compute the perimeter of inner and outer polygons 15 P-outer-... % make sure each input vector has n+1 elements 16 P (Pinner+P_outer)/2; 17 relErrEst-abs(P-inner-p-outer)/(2*P); %relative error bound 18 19 end 21 function L PolyLine(u,v) v(n+1) u and v are (n+1)-vectors with u(1)-u(n+1) and v(1) 23 %L is the perimeter of the polygon with vertices 24 %(u(1),V(1), (u(2),V(2)), , (u(n) 26 %function body of polyLine end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
