Question

6. Write a function with two inputs x and y and one output z. If x = y, then the output should be z = 2x + y and if x >y then
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Matlab code :

z1=func_z(10,-2);%testing the function using the inputs 10,-2
disp("the output of the given inputs x=10,y=-2 using the below function is: ");
disp(z1);%displaying the value i.e.(10-(-2))=12
z2=func_z(5,6);%testing the fuction using the inputs 5,6
disp("the output of the given inputs x=5,y=6 using the below function is: ");
disp(z2);%displaying the value i.e.(2*5+6)=16

function z=func_z(x,y)%writing the given condition into the function func_z using inputs x and y
if(x<=y)%using if statement to write the condition
z=2*x+y;
end
if(x>y)
z=x-y;
end
end

If you like the explanation please do give thumbs up........ Thank you and All the best

Add a comment
Know the answer?
Add Answer to:
6. Write a function with two inputs x and y and one output z. If x...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design a combinational circuit with three inputs, x , y, and z, and three outputs, A,...

    Design a combinational circuit with three inputs, x , y, and z, and three outputs, A, B , and C . When the binary input is 0, 1, 2, or 3, the binary output is one greater than the input. When the binary input is 4, 5, 6, or 7, the binary output is two less than the input. 1) Truth table 2) Logic circuit 3) Boolean function of A using minterms ( use Boolean algebra) 4) Boolean function of...

  • Given a circuit with three inputs x, y, and z, and that generates an output for...

    Given a circuit with three inputs x, y, and z, and that generates an output for the following three conditions Condition A: x is false and either y is false or z is true; Condition B: y is false and either x is true or z is false; Condition C: z is true and either x is false or y is false. Write the Truth Table/equation for the unsimplifed version and then repeat after simplfying.

  • [5 pts] Design a circuit with three inputs (x,y,z) and one output that outputs true if the binary value of the inputs i...

    [5 pts] Design a circuit with three inputs (x,y,z) and one output that outputs true if the binary value of the inputs is a perfect square (it's square root is an integer). Construct the truth table, simplify using a K-map, and draw out the logic circuit diagram [5 pts] Design a circuit with three inputs (x,y,z) and one output that outputs true if the binary value of the inputs is a perfect square (it's square root is an integer). Construct...

  • 3. A company has a production function with three inputs x, y and z, given by...

    3. A company has a production function with three inputs x, y and z, given by 2 1 1 f(x, y, z)=50x/5 y 5; 5. The total budget is $24,000 and the company can buy x, y and z at $80, $12 and $10 per unit respectively. What combination of inputs will maximize production? [12 ma 0- K 5C X

  • A firm uses two inputs x1 and x2 to produce output y. The production function is...

    A firm uses two inputs x1 and x2 to produce output y. The production function is given by f(x1, x2) = p min{2x1, x2}. The price of input 1 is 1 and the price of input 2 is 2. The price of output is 10. 4. A firm uses two inputs 21 and 22 to produce output y. The production function is given by f(x1, x2) = V min{2x1, x2}. The price of input 1 is 1 and the price...

  • Question #6 6 points Implement the function from the truth table below (X, Y, Z are...

    Question #6 6 points Implement the function from the truth table below (X, Y, Z are inputs. F is the output) using a) An 8:1 multiplexer b) A 4:1 multiplexer and one inverter c) A 2:1 multiplexer and two other logic gates Y z F 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 -

  • 8. Write a MATLAB function that will take as inputs a set of data (x,y) and...

    8. Write a MATLAB function that will take as inputs a set of data (x,y) and output the best estimate of the integral using a Romberg Array. The function should perform two trapezoidal integrations using the full interval and half the interval, and then combine these integrations in a Romberg Array. Your function should also output the relative error of the integral. Please note that the data entered may not be evenly spaced and your function should make sure that...

  • 3. Suppose x,y,z satisfy the competing species equations <(6 - 2x – 3y - 2) y(7...

    3. Suppose x,y,z satisfy the competing species equations <(6 - 2x – 3y - 2) y(7 - 2x - 3y - 22) z(5 - 2x - y -22) (a) (6 points) Find the critical point (0,Ye, ze) where ye, we >0, and sketch the nullclines and direction arrows in the yz-plane. (b) (6 points) Determine if (0, yc, ze) is stable. (c) (8 points) Determine if the critical point (2,0,0) is stable, where I > 0.

  • please solve then upload matlab code Thanks 1. The function f(z, y) (a-x)2 + b(y-12)2 is...

    please solve then upload matlab code Thanks 1. The function f(z, y) (a-x)2 + b(y-12)2 is called Rosenbrock's banana function. It is often used as a benchmarking test for optimization algorithms becatse it is easy to find the minimum by hand but often very difficult to find numerically. Throughout the problem, we will use the values a = 2 and b 10. You can plot this function using the following code: x3:0.1:3; y = -10:0.2:10; Cx,Ymeshgrid(x,y); Z(2-X).2 10* (Y-X. 2)....

  • Design a combinational circuit with three inputs, x, y, z, and three outputs, A, B, C....

    Design a combinational circuit with three inputs, x, y, z, and three outputs, A, B, C. When the binary input is 0, 1, 2, or 3, the binary output is one greater than the input. When the binary input is 4, 5, 6, or 7, the binary output is two less than the input.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT