PLEASE EXPLAIN/DISCUSS THE MATLAB CODES BELOW % Let's start the program % start the program   % request the user to input the desired option with regard the unit % if the user input is ‘MKS’, then the units will be in meters and seconds % If the user input is ‘FPS’, then the units will be in feet and seconds unit = input("Please choose a unit: MKS (meters and seconds) or FPS (feet and seconds): ", "s");   % conditional statements enable you to select at run time which block of code to execute % in the situation where the user has input “MKS” if (unit == "MKS" || unit == "mks") % gravity is equivalent to -9.81 gravity = -9.81; % in the situation where the user has input “FPS” elseif (unit == "FPS" || unit == "fps") % gravity is equivalent to -32.174 gravity = -32.174; else % in the situation where the user has input none of the provided options error = " Please enter an input only within the provided options "; % disp( ) displays the value of variable without printing the variable name % display error disp(error) % return control to the invoking program before it reaches the end of the script or function return % to terminate statements end % for the variables needed in accordance with the formula % request the user to input the desired value for the magnitude of the initial velocity Vo = input("Enter magnitude of the initial velocity: "); % request the user to input the desired value for the angle theta = input("Enter angle: "); % request the user to input the desired value for the height h = input("Enter height: "); % request the user to input the desired value for the acceleration ax = input("Enter acceleration: ");   % mathematical formula equations % formula equation for time time = (Vo.*sind(theta) + sqrt((Vo.*sind(theta)).^2-2*gravity*h)) / (-gravity); t = linspace(0,time);   % formula equation for velocity (x) velocityx = Vo*(cosd(theta));   % formula equation for velocity (y) velocityy = Vo*(sind(theta));   % formula equation for displacement (x) displacementx = (velocityx.*t) + ((1/2)*ax*(t.^2));   % formula equation for displacement (y) displacementy = (velocityy.*t) + ((1/2)*gravity*(t.^2));   % formula equation for final velocity (x) finalvelocityx = sqrt(velocityx.^2 + 2*ax*displacementx);   % formula equation for final velocity (y) finalvelocityy = sqrt(velocityy.^2 + 2*gravity*displacementy);   % formula equation for magnitude magnitude = sqrt((finalvelocityx.^2)+(finalvelocityy.^2));   % For Plotting % for figure 1 figure(1) % plot function is used to create a graphical representation % linewidth specifies the width of the line % -k = solid black plot (t, magnitude,'-k','linewidth',3) % title adds the specified title to the current axes or standalone visualization title('Magnitude of Velocity Versus Time') % labels the x-axis of the current axes or standalone visualization xlabel('Time') % labels the y-axis of the current axes or standalone visualization ylabel('Magnitude of Velocity') % displays the major grid lines for the current axes grid on % for figure 2 figure(2) % plot function is used to create a graphical representation % linewidth specifies the width of the line % -k = solid black   plot (displacementx,displacementy,'-k','LineWidth',3) % hold on is utilized to add a second line plot without deleting the existing line plot hold on % title adds the specified title to the current axes or standalone visualization title('Trajectory of the body')   % labels the x-axis of the current axes or standalone visualization xlabel("Horizontal Displacement(m)") % labels the y-axis of the current axes or standalone visualization ylabel("Vertical Displacement(m)") % displays the major grid lines for the current axes grid on % for figure 3 figure(3); % hold on is utilized to add a second line plot without deleting the existing line plot hold on % length(t) returns the length of the largest array dimension in t for n = 1:length(t) % plot function is used to create a graphical representation plot (displacementx(1:n),displacementy(1:n), '--r','linewidth',3) % labels the x-axis of the current axes or standalone visualization xlabel("Horizontal Displacement(m)") % labels the y-axis of the current axes or standalone visualization ylabel("Vertical Displacement(m)") % title adds the specified title to the current axes or standalone visualization title("Trajectory") % temporarily stops MATLAB execution and waits for the user to press any key pause(0.1) % hold on is utilized to add a second line plot without deleting the existing line plot hold on % for termination end

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
icon
Concept explainers
Question

PLEASE EXPLAIN/DISCUSS THE MATLAB CODES BELOW

% Let's start the program
% start the program
 
% request the user to input the desired option with regard the unit
% if the user input is ‘MKS’, then the units will be in meters and seconds
% If the user input is ‘FPS’, then the units will be in feet and seconds
unit = input("Please choose a unit: MKS (meters and seconds) or FPS (feet and seconds): ", "s");
 
% conditional statements enable you to select at run time which block of code to execute
% in the situation where the user has input “MKS”
if (unit == "MKS" || unit == "mks")
% gravity is equivalent to -9.81
gravity = -9.81;
% in the situation where the user has input “FPS”
elseif (unit == "FPS" || unit == "fps")
% gravity is equivalent to -32.174
gravity = -32.174;
else
% in the situation where the user has input none of the provided options
error = " Please enter an input only within the provided options ";
% disp( ) displays the value of variable without printing the variable name
% display error
disp(error)
% return control to the invoking program before it reaches the end of the script or function
return
% to terminate statements
end
% for the variables needed in accordance with the formula
% request the user to input the desired value for the magnitude of the initial velocity
Vo = input("Enter magnitude of the initial velocity: ");
% request the user to input the desired value for the angle
theta = input("Enter angle: ");
% request the user to input the desired value for the height
h = input("Enter height: ");
% request the user to input the desired value for the acceleration
ax = input("Enter acceleration: ");
 
% mathematical formula equations
% formula equation for time
time = (Vo.*sind(theta) + sqrt((Vo.*sind(theta)).^2-2*gravity*h)) / (-gravity);
t = linspace(0,time);
 
% formula equation for velocity (x)
velocityx = Vo*(cosd(theta));
 
% formula equation for velocity (y)
velocityy = Vo*(sind(theta));
 
% formula equation for displacement (x)
displacementx = (velocityx.*t) + ((1/2)*ax*(t.^2));
 
% formula equation for displacement (y)
displacementy = (velocityy.*t) + ((1/2)*gravity*(t.^2));
 
% formula equation for final velocity (x)
finalvelocityx = sqrt(velocityx.^2 + 2*ax*displacementx);
 
% formula equation for final velocity (y)
finalvelocityy = sqrt(velocityy.^2 + 2*gravity*displacementy);
 
% formula equation for magnitude
magnitude = sqrt((finalvelocityx.^2)+(finalvelocityy.^2));
 
% For Plotting
% for figure 1
figure(1)
% plot function is used to create a graphical representation
% linewidth specifies the width of the line
% -k = solid black
plot (t, magnitude,'-k','linewidth',3)
% title adds the specified title to the current axes or standalone visualization
title('Magnitude of Velocity Versus Time')
% labels the x-axis of the current axes or standalone visualization
xlabel('Time')
% labels the y-axis of the current axes or standalone visualization
ylabel('Magnitude of Velocity')
% displays the major grid lines for the current axes
grid on
% for figure 2
figure(2)
% plot function is used to create a graphical representation
% linewidth specifies the width of the line
% -k = solid black
 
plot (displacementx,displacementy,'-k','LineWidth',3)
% hold on is utilized to add a second line plot without deleting the existing line plot
hold on
% title adds the specified title to the current axes or standalone visualization
title('Trajectory of the body')
 
% labels the x-axis of the current axes or standalone visualization
xlabel("Horizontal Displacement(m)")
% labels the y-axis of the current axes or standalone visualization
ylabel("Vertical Displacement(m)")
% displays the major grid lines for the current axes
grid on
% for figure 3
figure(3);
% hold on is utilized to add a second line plot without deleting the existing line plot
hold on
% length(t) returns the length of the largest array dimension in t
for n = 1:length(t)
% plot function is used to create a graphical representation
plot (displacementx(1:n),displacementy(1:n), '--r','linewidth',3)
% labels the x-axis of the current axes or standalone visualization
xlabel("Horizontal Displacement(m)")
% labels the y-axis of the current axes or standalone visualization
ylabel("Vertical Displacement(m)")
% title adds the specified title to the current axes or standalone visualization
title("Trajectory")
% temporarily stops MATLAB execution and waits for the user to press any key
pause(0.1)
% hold on is utilized to add a second line plot without deleting the existing line plot
hold on
% for termination
end
Expert Solution
steps

Step by step

Solved in 8 steps

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY