Question: USE MATLAB! USE MATLAB! QUESTION 1: [20] A unit vector is a vector that has a certain direction, but a magnitude of 1. The equation

USE MATLAB!

USE MATLAB! USE MATLAB! QUESTION 1: [20] A unit vector is a

USE MATLAB!

QUESTION 1: [20] A unit vector is a vector that has a certain direction, but a magnitude of 1. The equation for a unit vector in two-dimensional space is: r x + y Write a script that prompts the user for x and y values (for example, in this case you can use x = 8, y=9), and then calculate the unit vector. MATLAB should display the following when you run the script. Enter the x-coordinate: 8 Enter the y-coordinate: 9 (red text indicates what the user will enter) You should use one of the output statements discussed in the lecture to output the unit vector, each value should only have 2 decimal places. The command window will display exactly the following: The unit vector of is: 0.66 0.75 QUESTION 2: (30) Create a local function at the end of the script named vecreverse" that will receive a 1 x n row vector and will return: (1) a vector with only even numbers in the original vector in reverse order, and (2) the average of these numbers. For example: >> x = [3 2 6 7 8 11 2 1 14]; >> (new_vec, avg] = vecreverse (x) new vec = 14 2 8 2 avg = 6.4000 In your script, test out your function with input x which is an array of 10 random integers in the range from 1 to 20 (Note: "mean()" Built-in function and conditional statements such as if-else, for-loop, while loop statements are not allowed

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!