Question: Matlab code Write a function that will do the following to all elements in an array and return the resulting array as output: 1) if

Matlab code

Write a function that will do the following to all elements in an array and return the resulting array as output: 1) if the element is at an odd array position (position 1, 3, 5, etc...) raise it to the power of that position 2) if the element is at an even array position (position 2, 4, 6, etc...) multiply it by that position Example: If the following array is passed in as a parameter: [1, 2, 3, 5, 2, 1] You would do the following: 1^1 2 * 2 3^3 5 * 4 2^5 1 * 6 and your output would be: [ 1, 4, 27, 20, 32, 6]. You can assume that you will only receive 1 dimensional arrays (or vectors).

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!