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)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.