Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions