Question: Array Manipulation. You are tasked with creating a MATLAB function that performs specific manipulations on an input array and produces an output array. Your function
Array Manipulation. You are tasked with creating a MATLAB function that performs specific manipulations
on an input array and produces an output array. Your function should take an array of integers as input and
return an array that meets certain conditions. Follow the instructions below to create the function:
Function Signature:
function outputArray manipulateArrayinputArray
Input:
The inputArray is a dimensional array of integers with a length of N N The array elements
are guaranteed to be within the range of to inclusive
Output:
The function should return an outputArray which is also a dimensional array of integers with the same length
as the inputArray.
Manipulation Conditions:
Your function needs to implement the following manipulations on the inputArray to create the outputArray:
a Double the values of evenindexed elements in the inputArray.
b Square the values of oddindexed elements in the inputArray.
c Leave primenumbered indices unchanged in the outputArray.
d Replace negative values in the inputArray with their absolute values in the outputArray.
Example:
If the inputArray is:
The outputArray should be:
Write a script to test your manipulateArray function using various input arrays. Ensure that the function
works correctly for different input cases and meets the specified conditions.
Include comments in your code to explain each step of your solution.
Remember to handle corner cases and edge scenarios gracefully.
Your task is to implement the manipulateArray function according to the given specifications and write the
testing script to verify its correctness.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
