## Solution Library

# Write a Script which Reads All the Values of an Array Using MATLAB

**Question**

- Consider a set of N numbers,
**myArray**, (represented as a row vector) which is not ordered. Write a function**myStats**which takes**myArray**and an integer**k**such that 1≤k≤N and returns the kth largest and kth smallest element in**myArray**. Your function should ensure the function is called with valid number of arguments and the validity of the arguments itself. Also note that, you cannot use any built-in functions to order the elements within**myArray**. You should write your own code to order the data, if necessary.

Write a script **helpMyStats.m **which reads all the elements of **myArray **and the value k from the user and displays the result by calling **myStats **function with the appropriate input data.

- Modify the function
**myStats**(from question-1) and write**myStats_2**so that the input argument k is optional. In case this argument is omitted, then the function**myStats_2**returns the smallest and the largest element in the**myArray**.

Write a script **helpMyStats_.m **which reads all the elements of **myArray **and the value k from the user and displays the result by calling **myStats_2 **function with the appropriate input data. Also test various ways to call **myStats_2**.

- Modify the function
**myStats_2**and write the function**myStrings**so that the function perform the same task with the myArray containing list of names(strings) instead of numbers.

Write a script **helpMyStrings.m **which reads all the names in **myArray **and the value k from the user and displays the result by calling **myStrings **function with the appropriate input data. Also test various ways to call **myStrings**.

**Summary**

This question belongs to MATLAB software and discusses about to write some functions and scripts that includes valid arguments and elements to obtain the required results.

**Answer is in MATLAB format**

Download Full Solution

## Comments

Rashathis is a very good website

maaniI have 50 questions for the same test your page is showing only 28

joeannehi can you please help or guide me to answer my assignments. thanks

joeannehi can anyone help or guide me to my assignments. thanks

MonikCristinaThis solution is perfect ...thanks

JaneteHello Allison,I love the 2nd image that you did! I also, had never heard of SumoPaint, is something that I will have to exolpre a bit! I understand completely the 52 (or so) youtube videos that you probably watched. Sometimes they have what you want, sometimes they don't! However, it is always satisfying when you are able to produce something that you have taught yourself. Great job!Debra 0 likes

SandeepPerfect bank of solution.

Oxanagreat !

Paul Brandon-Fritziusthanks for the quick response. the solution looks good. :)

tina Johnsonthnx for the answer. it was perfect. just the way i wanted it.

Giuseppeworks fine.