i am not getting correct output.please help

3 次查看(过去 30 天)
function [e]=eccentricity(a,b)
if (a||b==0)
disp('warning');
elseif a<b
temp=a;
a=b;
b=temp;
e=sqrt(1-(b^2/a^2));
else
e=sqrt(1-(b^2/a^2));
end
end

采纳的回答

madhan ravi
madhan ravi 2019-5-19
e = eccentricity(1,2) % function call
function e = eccentricity(a,b) % function definition , a & b assumed as scalars for this task
if any(ismember([a,b],0))
e = sprintf('warning');
elseif a < b
temp = a;
a = b;
b = temp;
e = sqrt(1-(b^2/a^2));
else
e = sqrt(1-(b^2/a^2));
end
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by