Problem 2 (10 points) You have learned about iteration, geometric transformations, and plotting. Now, we will make a sim

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Problem 2 (10 points) You have learned about iteration, geometric transformations, and plotting. Now, we will make a sim

Post by answerhappygod »

Problem 2 10 Points You Have Learned About Iteration Geometric Transformations And Plotting Now We Will Make A Sim 1
Problem 2 10 Points You Have Learned About Iteration Geometric Transformations And Plotting Now We Will Make A Sim 1 (132.01 KiB) Viewed 43 times
Problem 2 10 Points You Have Learned About Iteration Geometric Transformations And Plotting Now We Will Make A Sim 2
Problem 2 10 Points You Have Learned About Iteration Geometric Transformations And Plotting Now We Will Make A Sim 2 (192.57 KiB) Viewed 43 times
clock_animation.MP4 file name
Problem 2 (10 points) You have learned about iteration, geometric transformations, and plotting. Now, we will make a simple clock using these. Create a function called plotTime.m that accepts hour and minute as inputs. The function will plot a circle, a minute hand, and an hour hand for the current hour and minute. • Circle: plot the unit circle the using parametric equations given by Eq. (1) of Problem 1. Make the plot a blue line. Hint 1: use the command axis equal after the command plot to correct the aspect ratio. Minute hand: create an initial position for the minute hand (a long rect- angular box) with the line = minuteHand [-w/2 w/2 w/2 -w/2 -w/2; 0 0 LL 0]; where w is the width and L is the length of the minute hand. (Use w = 0.05, L = 0.9). The first row contains x coordinates and the second row contains the corresponding y coordinates. Calculate the current rotation angle of the minute hand from the given input minute. Rotate the minute hand clockwise, using a rotation matrix, until it reaches the minute spec- ified in the input to your function plotTime. Save the coordinates in

the variable rotatedMinuteHand. Plot the minute hand with the rotated position. Make the outline of the minute hand green. Hint 2: You can plot the rectangular box by using the following syntax: % plot x coords (first row) vs y coords (second row) plot( rotatedMinuteHand(1,:),rotatedMinuteHand (2,:),'g'); • Hour hand: create an initial position for the hour hand (a short rectangular box) with the line hourHand = [-w/2 w/2 w/2 -w/2 -w/2; 0 0 L/2 L/2 0]; Calculate the current rotation angle of the hour hand from the given input hour. Rotate the hour hand clockwise using a rotation matrix and save the coordinates in rotatedHourHand. Plot the hour hand with the rotated position. Make the outline of the hour hand red. Now, create an m-file script called clockScript.m that will run your clock for 12 hours, starting at midnight. Use a nested for loop to loop through the hours from 0 to 12, and for each hour loop through the minutes from 0 to 59, and call your plotTime function for each combination of minute and hour. You might want to use Matlab built-in functions such as clf to clear the plot before drawing, and the pause (0.05) function to slow down the plot changes inside the for loop. Upload clockScript.m and plotTime.m to GauchoSpace. Note: The clock animation, clock_animation.mp4 that you downloaded with the homework shows what your clock animation should look like. If you are on a Mac, this video may not run properly with the Quicktime video player (you will know if this is the case because the video will look pretty weird). It should run on the Mac with the Elmedia Player, which you can download from the Web for free.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply