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](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3c55aa911e_80266f3c55a4bcfc.jpg)
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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
