Question: In Matlab, please Write a function with header [ result] myoperation (a, b, operation), where a and b are double arrays and operation is a

 In Matlab, please Write a function with header [ result] myoperation

In Matlab, please

Write a function with header [ result] myoperation (a, b, operation), where a and b are double arrays and operation is a string that is either 'plus', 'minus', 'mult', 'div', or 'pow' , and result should be computed as a b, a - b, a*b, a/b. and a^b for the respective element-wise operations. The function should use ifelseif/else and the strcmp function. Run the following test script load myname x = myvec (1:3) y - myvec (4:6) resplsmyOperation (x,y, 'plus') resmin = myope ration (x,y,,minus, ) resmulmyOperation (x, y, 'mult') resdiv myOperation (x, y, 'div') respow myope ration (x,y,' pow') re serr = myoperation(x,y,, pot, ) 2. Write a function with the header [result] same thing as the function in Question 1 above, but using the switch-case construct. Also, if the input string operation is none of the above, then output an error message with the text-Unknown operation ", where is the input string. Run the same test script as in Question 1 using myOperationSwitch instead of myOperation. myoperationswitch (a, b, operation), which does the Write a function with header [ result] myoperation (a, b, operation), where a and b are double arrays and operation is a string that is either 'plus', 'minus', 'mult', 'div', or 'pow' , and result should be computed as a b, a - b, a*b, a/b. and a^b for the respective element-wise operations. The function should use ifelseif/else and the strcmp function. Run the following test script load myname x = myvec (1:3) y - myvec (4:6) resplsmyOperation (x,y, 'plus') resmin = myope ration (x,y,,minus, ) resmulmyOperation (x, y, 'mult') resdiv myOperation (x, y, 'div') respow myope ration (x,y,' pow') re serr = myoperation(x,y,, pot, ) 2. Write a function with the header [result] same thing as the function in Question 1 above, but using the switch-case construct. Also, if the input string operation is none of the above, then output an error message with the text-Unknown operation ", where is the input string. Run the same test script as in Question 1 using myOperationSwitch instead of myOperation. myoperationswitch (a, b, operation), which does the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!