Old Exam Question: Order Write a function called order that has two inputs, in1
ID: 3873596 • Letter: O
Question
Old Exam Question: Order Write a function called order that has two inputs, in1 and in2, and two outputs, out1 and out2. out1 should be the lower value of in1 and in2. out2 should be the higher value of in1 and in2. Note that if both inputs are the same, both outputs are the same. You can accomplish this task any way you see fit. Your Function Sve C Reset MATLAB Documentation function [o1, o21-order(in1,in2) 3 if (01 02) 5 elseif (o1>o2) order- inl,in2 order-in2, inl 8 end Code to call your function C Reset 1 o1, o21order(5,10) 3 [01, 02] = order(1.1,0.5)Explanation / Answer
Matlab code for the function order:
function [o1,o2] = order(in1,in2)
if(in1 <= in2)
o1 = in1;o2 = in2;
else
o1 = in2;o2 = in1;
end
end
Sample Output:
>> [o1,o2] = order(10,5)
o1 =
5
o2 =
10
>> [o1,o2] = order(5,5)
o1 =
5
o2 =
5
>> [o1,o2] = order(2,5)
o1 =
2
o2 =
5
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.