× ENGR 102-Homework 3. https ecampuswww.edu/bbcswebdav/pid-4939 181-dt-content-r
ID: 3911462 • Letter: #
Question
× ENGR 102-Homework 3. https ecampuswww.edu/bbcswebdav/pid-4939 181-dt-content-rid-415568131 1805 ENGRT Mr. Spada ENGR 102: Engineering Problem Solving II Homework 3: 1D Arrays and Plots Solve all problems in a single seript file in Matlab. Ensure that your file is saved as LastName_FirstName HW3 before submitting, Submit your file to eCampus by Sunday 7/8/2018 at 11:59 PM. Create sets of reference values for sine, cosine, and tangent for angles ranging from 0 to 2?. Do this in two ways: (1) use a spacing of 0.5 radians, and (2) use 10 linear-spacedl points. Use output functlons to display the values in a manner which will be easily read by the user 1. 2. A spring's displacement in the x direction is defirned by the fallowing equation: where: x is the displacement of the spring at a given time, t; A is the maximunm displacement, and is the angular frequency [dependent upon the spring constant) Find the displacement of the spring from times ranging from 0 to 20 seconds at one second intervals. The maximum displacement af tho spring is known to be 3 inches. The angular frequency is known to be 0.5 radians per second.Explanation / Answer
Please find the required MATLAB function as:
%=================================================
function [ ] = cannonball_distance( v0 )
g=9.81; % gravitational acceleration
angles = 0:pi/32:pi/2; % Vector of angles to verify distances
max_dist=0; % Initialization
for i=angles % This loop calculates the distances for each angle and keeps only the maximum
distance = (v0^2)*sin(2*i)/g;
if(distance>max_dist)
max_dist=distance;
max_angle=i;
end
fprintf(' At angle = %f , distance = %f ',rad2deg(i),distance);
end
fprintf(' The cannonball achieves maximum distance of %f meters at the angle of %f degrees!! ',max_dist,rad2deg(max_angle));
end
%============================================
Sample output:
>> cannonball_distance(125)
At angle = 0.000000 , distance = 0.000000
At angle = 5.625000 , distance = 310.732547
At angle = 11.250000 , distance = 609.523816
At angle = 16.875000 , distance = 884.891426
At angle = 22.500000 , distance = 1126.253156
At angle = 28.125000 , distance = 1324.333608
At angle = 33.750000 , distance = 1471.520662
At angle = 39.375000 , distance = 1562.158003
At angle = 45.000000 , distance = 1592.762487
At angle = 50.625000 , distance = 1562.158003
At angle = 56.250000 , distance = 1471.520662
At angle = 61.875000 , distance = 1324.333608
At angle = 67.500000 , distance = 1126.253156
At angle = 73.125000 , distance = 884.891426
At angle = 78.750000 , distance = 609.523816
At angle = 84.375000 , distance = 310.732547
At angle = 90.000000 , distance = 0.000000
The cannonball achieves maximum distance of 1592.762487 meters at the angle of 45.000000 degrees!!
%==========================================================
NOTE:
1) The function file must be the same as the name of the function. For example, in the code above, it must be saved as "cannonball_distance.m"
2) To call the function use: cannonball_distance(<initial velcity value>) from the MATLAB command shell.
Hope this helps! ******************* Please Thumbs Up! *******************
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.