Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MATLAB. For the following problem, develop a flow chart The eccentricity of an e

ID: 3846584 • Letter: M

Question

MATLAB. For the following problem, develop a flow chart

The eccentricity of an ellipse is defined as Squareroot 1 - (b/a)^2 where a is the semimajor axis and b is the semiminor axis of the ellipse. A script prompts the user for the values of a and b. As division by 0 is not possible, the script prints an error message if the value of a is 0 (it ignores any other errors, however). If a is not 0, the script calls a function to calculate and returns the eccentricity, and then the script prints the result. Write the script and the function.

Explanation / Answer

// Fucntion to claculate Eccentricity

function eccen = calcEccentricity(a,b)
if(a==0)
fprintf('division by zero error ')
else
eccen= sqrt(1-((b/a)^2));
fprintf(' Eccentricity : %f ',eccen);
end
end

// Script to call function
a=input(' enter semi-major axis (a) : ');
b=input(' enter semi-minor axis (b) :');
calcEccentricity(a,b)