Complete the implementation of the VectorRotate function. The function rotates the input column vector, a, by...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Complete the implementation of the VectorRotate function. The function rotates the input column vector, a, by 45 degrees to get b. It then rotates b by 45 degrees to get c. It then checks that the C is perpendicular to a to a tolerance of le-10. If they are equal within tolerance, then d should equal 1. Otherwise, d should equal zero. Step 1: Create a rotation matrix R = cos(0) -sin(e) sin(0) cos(0) Step 2: Rotate the vector by 45 degrees twice. To rotate a 2D column vector a, by an angle 0, apply the matrix multiplication a_rot = Ra. Step 3: Use an if statement to check whether the corresponding vector C is perpendicular to a. Because of errors associated with floating point arithmetic, we do not want to check orthogonality by checking whether the dot product is equal to zero. Instead, you should check whether the absolute value of the dot product is below a tolerance of le-10. If it is, the vectors are orthogonal and d should have a value of 1. Otherwise, d should have a value of 0. Function Template: function [R,b,c,d] = VectorRotate(a) R = 0; %Create rotation matrix that rotates by 45 degrees b = 0; %rotate a by 45 degrees C = 0; %rotate b by 45 degrees %if statement to calculate d end Test Example [R,b,c,d] = VectorRotate([1;1]) should return R = rotation_matrix (can't give away what this looks like - sorry), b = [0;1.4142],c = [-1;1], and d -1. Hints: 1. For information on how to create a matrix, read section 9.2 of the Introduction to Programming in MATLAB document on Blackboard. 2. For information on matrix multiplication, read section 9.7 of the Introduction to Programming in MATLAB document on Blackboard. 3. For information on if statements, read section 10.2 of the Introduction to Programming in MATLAB document on Blackboard. Complete the implementation of the VectorRotate function. The function rotates the input column vector, a, by 45 degrees to get b. It then rotates b by 45 degrees to get c. It then checks that the C is perpendicular to a to a tolerance of le-10. If they are equal within tolerance, then d should equal 1. Otherwise, d should equal zero. Step 1: Create a rotation matrix R = cos(0) -sin(e) sin(0) cos(0) Step 2: Rotate the vector by 45 degrees twice. To rotate a 2D column vector a, by an angle 0, apply the matrix multiplication a_rot = Ra. Step 3: Use an if statement to check whether the corresponding vector C is perpendicular to a. Because of errors associated with floating point arithmetic, we do not want to check orthogonality by checking whether the dot product is equal to zero. Instead, you should check whether the absolute value of the dot product is below a tolerance of le-10. If it is, the vectors are orthogonal and d should have a value of 1. Otherwise, d should have a value of 0. Function Template: function [R,b,c,d] = VectorRotate(a) R = 0; %Create rotation matrix that rotates by 45 degrees b = 0; %rotate a by 45 degrees C = 0; %rotate b by 45 degrees %if statement to calculate d end Test Example [R,b,c,d] = VectorRotate([1;1]) should return R = rotation_matrix (can't give away what this looks like - sorry), b = [0;1.4142],c = [-1;1], and d -1. Hints: 1. For information on how to create a matrix, read section 9.2 of the Introduction to Programming in MATLAB document on Blackboard. 2. For information on matrix multiplication, read section 9.7 of the Introduction to Programming in MATLAB document on Blackboard. 3. For information on if statements, read section 10.2 of the Introduction to Programming in MATLAB document on Blackboard.
Expert Answer:
Answer rating: 100% (QA)
1 We have two scripts function and driver program be... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Complete the implementation of the ArrayStack class presented in this chapter. Specifically, complete the implementations of the isEmpty, size, and toString methods.
-
Complete the implementation of the LinkedQueue class presented in this chapter. Specifically, complete the implementations of the first, isEmpty, size, and toString methods.
-
Complete the implementation of the CircularArrayQueue class described in this chapter, including all methods.
-
A non reactive/conservative contaminant is dumped on the ground level and it leaches to the groundwater vertically and takes half day for reaching the groundwater by travelling through unsaturated...
-
Explain how the capacity utilization rate and the interest rate affect the level of investment.
-
Briefly describe how an island arc forms.
-
Discuss the three primary reasons for applying contingency funds to projects.
-
Turner, Inc. began work on a $7,000,000 contract in 2010 to construct an office building. During 2010, Turner, Inc. incurred costs of $1,700,000, billed their customers for $1,200,000, and collected...
-
1.Two identical ping pong balls are rolling toward each other. Ball one is shot to the east at a speed of 1.40 m/s and ball two is shot to the west at 6.20 m/s. They do not hit head on but have a...
-
Show (as circles-and-arrows diagrams) the finite automata for Exercise 2.1. Data from Exercise 2.1: Write regular expressions to capture the following. (a) Strings in C. These are delimited by double...
-
Quantity a) Start at a price of $3 per bushel and increase the price to $6 in $.50 increm Quantity demanded Price supplied (billions) (billions) $3.00 56.50 16.50 $3.50 49.25 19.25 $4.00 42.00 22.00...
-
Suppose joel decides to go fishing at Lake Veronica on his day off from work, but he faces a choice: he can fish the north, south, east, or west side of the lake. His expected catch for the day is as...
-
Find the solution of the given initial value problem in explicit form. 1 y' = (1 - 13x)y, y(0) = -3 y(x) =
-
Are there alternatives to the common-law control test you can think of that might be better because they draw either brighter (more certain) lines or more appropriate distinctions between those...
-
Suppose that over one year the US Dollar depreciates by 5%. Calculate the continuously compounded depreciation rate of the US Dollar.
-
Q.5(b): Figure shows an arrangement known as a Helmholtz coil. It consists of two circular coaxial coils, each of N turns and radius R, separated by a distance 2R. The coils carry equal currents I in...
-
Why do CPA firms sometimes use a combination of positive and negative confirmations on the same audit?
-
A study found that the average American buys 4.6 movie tickets per year, compared to an average of 3.2 in Ireland. Assuming that the data values in file XR04049 represent the number of movie ticket...
-
Given the situation described in Exercise 12.85, suppose the groups are contrived so that each group contains one driver who is under 21 years of age, one driver who is between 22 and 60, and one...
-
A manufacturer informs a customers design engineers that the mean tensile strength of its rivets is at least 3000 pounds. A test is set up to measure the tensile strength of a sample of rivets, with...
-
A stirrer-container assembly contains a certain amount of fluid. The stirrer performs \(3 \mathrm{hp}\) work on the system. The heat developed by stirring is \(4000 \mathrm{~kJ} / \mathrm{h}\) and is...
-
A system consisting of a gas confined in a cylinder undergoes a series of processes shown in Fig. 2.11. During the process A-1-B, \(70 \mathrm{~kJ}\) of heat is added while it does 45 \(\mathrm{kJ}\)...
-
Derive the mathematical expression of the first law of thermodynamics.
Study smarter with the SolutionInn App