Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
%ME3255 Homework 3
%Ryan Hyatt
%See README.m
%TODO - A better description.
clc
clearvars
vmag = 5; %input initial speed.
height = 1.27; %target height.
y0 = 1.72; %the initial height of the projectile.
a = -9.81; %downward acceleration due to gravity.
delta_x = 2.37; %horizontal displacement
es = 1e-5;%accuracy?
dx = 1e-6;
maxiter = 10000;
guess = 25; % value of initial guess, if the function requires one.
thetas = linspace(15,65);
heights = ones(1,length(thetas));
i = 0;
for i = 1:length(thetas)
heights(i) = projectile(thetas(i), vmag)-height;
end
plot(thetas, heights)
%Newton's method.
[root(1),ea(1),iter(1)] = newtraph(@(theta) projectile(theta, vmag) - height,...
@(theta) dprojectile_dtheta(theta, vmag),...
guess, es, maxiter) % 1
%False Position Method
xl = 0;
xu = 30;
[root(2),fx,ea(2),iter(2)]=falsepos(@(theta) (projectile(theta, vmag) - height)...
,xl,xu,es,maxiter) %2
%Bisect Method
[root(3),fx,ea(3),iter(3)]=bisect(@(theta) (projectile(theta, vmag) - height)...
,xl,xu,es,maxiter) %3
%Modified Secant
[root(4),ea(4),iter(4)]=mod_secant(@(theta) (projectile(theta, vmag) - height),...
dx,guess,es,maxiter) %4
table = [root',ea',iter']