ml-1-matlab-basics-a5wylzeo.pdf ML-1: Basics of MATLAB Trajectories without Air Friction BACKGROUND INFO This exercise will use MATLAB to calculate and plot the frictionless trajectories of a...

1 answer below »
DUMMY


ml-1-matlab-basics-a5wylzeo.pdf ML-1: Basics of MATLAB Trajectories without Air Friction BACKGROUND INFO This exercise will use MATLAB to calculate and plot the frictionless trajectories of a projectile such as you have studied in physics or will see soon. You will learn to use MATLAB to define variable names, use trig functions, solve a quadratic equation, define an array, use array multiplication and exponentiation (“ .* ” and “ .^ ” in MATLAB) to calculate arrays of x- and y-points, and then plot these points to see the trajectory. The problem is illustrated in Figure 1. A ball is projected at an angle of 60° with an initial velocity of 100 m/sec and traces out a parabolic trajectory as shown in Figure 1. Similar to the warm-up exercise, we want to find the distance x2 - x1 for several different heights, y. The initial velocity can be broken into a horizontal and vertical component, Vox and Voy, and then the usual kinematic equations can be used for the x- and y-displacement. Since there is no horizontal force in the x-direction, the x-component (distance) after an elapsed time t is given by: x = Vox t = Vo cos(60)t In the y-direction (height) there is a constant downward acceleration vector, g = -9.8 m/s2, as well as the initial upward component of velocity, Voy = Vosin(60), and the height of the ball at a time t is given by: y = Voyt + .5gt2 (same as: y = y0+Voyt + ½gt2) Assign g to be a negative number because it is a downward vector. The instantaneous y-velocity is given by: Vy = Voy + gt At the top of the trajectory Vy = 0, so the time to reach the top can be found from: ttop = -Voy /g. So, the first step is to solve the warmup exercise and review trajectory physics, and the next step is to become acquainted with how MATLAB functions so that it may be used to solve this and other real-world problems. H ei gh t ( m ) Vo = 100 m/s 60 ° x1 x2 y Figure 1. Height vs. Distance for projectile motion problem Distance (m) y x vo = 200 m/s y x 50o y x ymax = ? WARM-UP EXERCISE Solve by hand to find the maximum height and total time that the ball is in the air for a ball projected with an initial velocity of 200 m/s at an angle of 50o (from a height of 0). Show all formulae used and all work with interim values. P1. Calculate the maximum height y that the ball reaches in flight: a. Formulae used: ____________________________________________________ _____________________________________________________________________ b. Solution: _________________________________________________________ _____________________________________________________________________ ____________________________________________________________________________________________ ____________________________________________________________________________________________ P2. Calculate the length of time that the ball is in the air: a. Formulae used: ____________________________________________________ _____________________________________________________________________ b. Solution: _________________________________________________________ _____________________________________________________________________ ____________________________________________________________________________________________ ____________________________________________________________________________________________ GETTING STARTED: • To write the m-file by starting new:  In the Command window, choose File => New => M-file. The Editor/Debugger window will open. You may begin typing the m-file. The contents can be generated by extracting the relevant commands from the diary file (that should be executable). Then you will Save as: LastName_ML1.m in your directory. • To run your m-file:  Return to the Command Window and run the m-file by typing LastName_ML1. It should run; otherwise you will need to check for errors and make corrections in order to get the appropriate output and figures.  If you get error messages, you may have an invalid command or made a typographical error. Check your code and make the correction.  Test your program with your answers from the warm up exercise to ensure its working correctly! t = ? MATLAB EXERCISE Use my pseudocode to begin writing the code and take note of the details required %Start with a friendly greeting %Ask user for required inputs %Solve for initial velocities %Solve for the maximum height the ball reaches • Return answer to the user in a sentence %Solve for the length of time the ball is in the air • Return answer to the user in a sentence %Create a vector for time with 100 values %Plot height versus time • Label the plot axes with units • Have a title • Choose a marker %Plot height versus distance • Don’t overwrite your previous figure! • Label the plot axes with units • Have a title • Choose a new marker Here is one example of a user interface: To submit: Upload to Canvas your m-file!!!!!!! RUBRIC Points Upload .m file to Canvas with correct name 5 File runs without errors and returns correct values. • Max height • Time in air • (test with an initial velocity of 200 m/s at an angle of 50o ) 30 Program has a clean user interface/ formatting 10 File correctly creates 2 figures with proper labels • X axis with name and units • Y axis with name and units • Title • Distinct marker • 100 points on the plot 30 Program uses appropriate commands as requested • (fprintf vs. display) 10 Program Clarity • Commented thoroughly and cleanly • Formatted appropriately (indentations/parentheses) 15 Total 100 BONUS CHALLENGE The following challenge is optional for students looking to challenge themselves. • Take the program above and change it to include a user input of an initial height. • In addition to the required code, solve for the total (x) distance traveled by the ball. • Update all the necessary equations • Save the file as LastName_BML1.m • Upload only this file to BB. If you are successful you will receive three (3) bonus points on this activity ML-1: Basics of MATLAB y x y x y x high-yg24gcwk.txt 179 291 382 472 573 682 793 896 993 1077 1173 1271 1366 1472 1584 1681 1789 1885 1979 2075 2166 2268 2368 2474 2566 2663 2764 2878 2984 3078 low-dpuo3ymw.txt 169 266 370 462 558 661 766 872 972 1064 1163 1260 1363 1457 1562 1665 1764 1865 1962 2057 2153 2256 2354 2458 2555 2650 2748 2856 2965 3057 matlab-basics-activity-1wdpptjx.pdf Matlab Basics: Hand Out 1. Circle the bad variable names: • Donotpassgodonotcollect$200 • Two_nums • 2BR02B • Mult2 • Is_this_Valid? • GClefSign 2. Answer the following assuming: T=[9 10 ; 11 12] V=[2 4 ; 6 8 ; 10 12] • A = T (1,1) + V (1,1) = • E = V ( : , 2)+T ( : , 2) = • J = T (1 , : ) .* V ( 1 , : ) = 3. In your own words, what does the following code return?: Red=[6:2:24] 4. Search the help menu for the randi function. Write a command that generates 20 random integers between -5 and 5. Practice Program: AGE_Eval Hints: • Use all of the input/output commands: disp(), input(), and fprintf() • Use single quotes to indicate text. • Use a double apostrophe to show possession: Bob’s Hat  ‘Bob’’s Hat’ • Make sure you suppress the echo with semicolons! • Use %2i as your variable placement in the frprintf command. The “i” stands for integer. See the Matlab help for more options! Write your first program: Data Import and Analysis The temperatures for the month of September are located in a file on Blackboard. Write a Matlab code in a script file that does the following: • Load both files • Plot the Low and High data together on a plot so that it looks EXACTLY like the picture below. o Don’t forget the title, labels and legend!
Answered 5 days AfterJul 10, 2021

Answer To: ml-1-matlab-basics-a5wylzeo.pdf ML-1: Basics of MATLAB Trajectories without Air Friction BACKGROUND...

Jithinraj answered on Jul 15 2021
143 Votes
Assignment 1
1) Circle the bad variable names:
a. Is_this_Valid?
b. Donotpassgodonotcollect$200
2) Answer the following assuming
T = [9 10; 11 12]
V = [2 4; 6 8; 10 12]
· A = T(1,1 )+ V(1,1)
· 11 [ T(1,1) points first element in T matrix 9+ V(1,1) points to first element in the V matrix 2]
· E = V(:,2) + T(:,2)
· couldn’t add because of matrix size mismatch
· J = T(1,: ).*(1,: )
· [18 40]
3) In your own words, what does the following code return?
Red = [6:2:24]
    code returns error
4) Search the help menu for the randi function. Write a command that generates 20 random integers between -5 and 5.
C = randi([-5 5], 5,4);
5) Import and analysis data
code:
high = importdata('high-yg24gcwk.txt'); % import .txt file
low = importdata('low-dpuo3ymw.txt'); %...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here