Question: Using MATLAB, Write a function ShowNum(vec, pos) that will receive a vector as the first input argument, and pos as the 2nd input argument. The

Using MATLAB, Write a function ShowNum(vec, pos) that will receive a vector as the first input argument, and pos as the 2nd input argument. The function has no output argument. Inside the function, a for-loop is used to display the value of the elements at odd numbered positions if the input pos is 1, or even positions if the input pos is 2 in the following format. As an example, your function should work as below:

>> vec = rand(1, 10);

>> ShowNum(vec, 1)

The number at position 1 is 0.81.

The number at position 3 is 0.13.

The number at position 5 is 0.63.

The number at position 7 is 0.28.

The number at position 9 is 0.96.

>> ShowNum(vec, 2)

The number at position 2 is 0.34.

The number at position 4 is 0.22.

The number at position 6 is 0.89.

The number at position 8 is 0.54.

The number at position 10 is 0.12.

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!