Question: I need this in Matlab please Array and Conditional Statement Write a function that takes an array as an input, and returns an array as

I need this in Matlab please

Array and Conditional Statement

Write a function that takes an array as an input, and returns an array as an output.

Your function should check to make sure that the array has more than one element. If it does not, it should return an empty array.

If the array has more than one element, your output should be an array with two elements. The first element should be the first element of the input array. The second element should be the last element of the input array.

Please look up the "length" function in MATLAB to help you with this problem.

Output Should Include

Assessment: Incorrect

Submit

Assessment result: correct

Empty Case

Assessment result: incorrect

Singular Case

Variable output must be of size [0 0]. It is currently of size [1 1]. Check where the variable is assigned a value.

Your function doesn't work with an individual number!

Assessment result: incorrect

Random Arrays

Variable output must be of size [1 2]. It is currently of size [1 80]. Check where the variable is assigned a value.

Your function didn't work with at least one random array with length greater than 2!

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!