Write a function eqfn that will calculate f(x) = x 2 1 x for all elements of x. Since division by 0 is not possible, if any element in x is zero, the function will instead return a flag of -99. Here are examples of using this function:
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:4| Question number:14.4
All Answers
total answers (1)
function fofx = eqfn(x)
if any(any(x==0))
fofx = -99;
else
fofx = x.^2 + 1./x;
end
end
need an explanation for this answer? contact us directly to get an explanation for this answer