Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function final = fxy4F_name(x, y)
- % FUNCTION: Calculates "final" based on given numbers "x" and "y".
- %
- % INPUTS:
- % 1) x: The x input.
- % 2) y: The y input.
- %
- % OUTPUTS:
- % 1) final: The final product of the calculation.
- %--------CALCULATIONS--------
- %If x and y are more than or equal to 0.
- if (x >= 0) && (y >= 0)
- final = x^2 + y;
- %If x is more than or equal to 0 and y is less than 0.
- elseif (x >= 0) && (y < 0)
- final = x * y;
- %If x is less than 0 and y is more than or equal to 0.
- elseif (x < 0) && (y >= 0)
- final = x + y^2;
- %If x and y are less than 0.
- elseif (x < 0) && (y < 0)
- final = x^2 / y^2;
- end
- %--------OUTPUTS--------
- %Prints out results.
- fprintf('f(%d,%d) = %0.2f', x, y, final)
Advertisement
Add Comment
Please, Sign In to add comment