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

Write an m-file function that will take a scalar input, Input, and return two sc

ID: 3681423 • Letter: W

Question

Write an m-file function that will take a scalar input, Input, and return two scalars, Output1 and Output2, based on the following rules:

If Input is even, then Output1 is 0Otherwise:

If Input is negative, then Output1 is -1

If Input is greater than 10 but less than or equal to 100, Output1 is +1

Otherwise, Output1 is +2

Output2 has an initial value of Output1*Input

If Output2 is negative or odd, Output2 is Input.

** Hint: the built in function mod() execute a modular division and can return the integer remainder of a division problem.

Explanation / Answer

Your question is not so clear yaar. Anyways, I tried answering if for you. If you need any modifications, just get back to me, so that I'll sort it out for you again.

function [Output1, Output2] = Decide(Input)

Output1 = 0;

if(mod(Input, 2) == 0)%If Input is even, then Output1 is 0

   Output1 = 0;

else

   if(Input < 0)%If Input is negative, then Output1 is -1

   Output1 = -1;

   else if(Input > 10 && Input <= 100)%If Input is greater than 10 but less than or equal to 100, Output1 is +1

   Output1 = Output1 + 1;

   else %Otherwise, Output1 is +2

   Output1 = Output1 + 2;

   end

   end

end

Output2 = Output1 * Input; %Output2 has an initial value of Output1*Input

if(Output2 < 0 || mod(Output2, 2) == 1)%If Output2 is negative or odd, Output2 is Input.

Output2 = Input;

end

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote