Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 (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 operationStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started