Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Plot Trajectory of Projectile from Assignment launch to max height in MATLAB ASSIS Part 2 Revise code so that t end is general --- i.e.

Plot Trajectory of Projectile from Assignment launch to max height in MATLAB ASSIS Part 2

Revise code so that t end is "general" --- i.e. calculated from theory

Hardcode all inputs (like Launch angle (0), Initial velocity (V.), Initial Position (yo)

no need to prove you can do 'user input' here

Make Certain that comments are "best ever and that appropriate use of sections is included Plot the trajectory of the projectile

Use subplot to make plots of (y vs. x), (y vs. t) and (x vs. t)

Use sprintf (or other) to add key values in to title

Use appropriate titles for plots and axes

The changes I made to my code another way, having issues getting it to run. Variable undefine and not sure if plot will plot correctly. Not exactly sure how to fix it. Here is the code:

%Projectile Motion - Project (v1): Motion to Max Height

clc; clear all; close all;

%% Governing Equations

%x = x0 + V0x * t + 0.5 * ax * t^2 %y = y0 + V0y * t + 0.5 8 ay * t^2

%% Initial Conditions

theta = 25; %degrees %dt = 0.10; %s

y0 = 2; %m x0 = 0; %m

V0 = 15; %m/s

ay = -9.8; %m/s^2 ax = abs(ay) * sin(theta); %m/s^2

r = deg2rad(45); %max height

%% Calculate Derived Quantities

%need theta_radians %need V0x, V0y

%theta_rad = 1.22173; %V0x = V0 * cos(theta_rad); %V0y = V0 * sin(theta_rad);

V0x = V0 * cos(r); V0y = V0 * sin(r)

%Create the time vector

%x = start : stepsize : end

%t_start = 0; %t_end = 3; %numstep = 30;

%t = linspace(t_start, t_end, numstep);

t_end = (-V0y + sqrt(V0y^2 - 2 * ay * y)) / (-ay); %generalize

t = 0 : 0.01 : t_end;

%Calculate x-position and y-position as fxns of time

x = x0 + (V0x * t) + 0.5 * ax * t.^2; y = y0 + (V0y * t) + 0.5 * ay * t.^2;

%% Plot

%plot(t(1:1),y(1:1))

%z=sprintf('Trajectory of Projectile with V0= %f and Angle %f degrees', V0, theta); %title(z)

subplot(3,1,1) plot(x,y) str=sprintf('Plot of y vs for t=0 to %f', t_end); title(str); %title(z) xlabel('Distance: meters') ylabel('Time: seconds')

subplot(3,2,5) plot(t,x) str=sprintf('Plot of y vs for t=0 to %f', t_end); title(str); %title(z) ylabel('Distance: meters') xlabel('Time: seconds')

subplot(3,2,3) plot(t,y) str=sprintf('Plot of y vs for t=0 to %f', t_end); title(str); %title(z) ylabel('Distance: meters') xlabel('Time: seconds')

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions