Answer To: Northeastern University ML-1: Basics of MATLAB Trajectories without Air Friction BACKGROUND INFO...
Kshitij answered on Feb 01 2021
Projectile/New folder/ans2.m
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,: )
Projectile/New folder/ans5.m
S = 'Welcome';
disp(S)
prompt = 'What is the lower value? ';
x = input(prompt)
prompt1 = 'What is the maximum value? ';
y = input(prompt1)
%%
%add
z=x+y;
disp(z)
%%
%sub
z2=y-x;
fprintf('your combined age is %2i\n',z);
fprintf('your age difference is %2i\n',z2);
Projectile/New folder/ans6.m
Low=importdata('low.txt');
High=importdata('high.txt');
Time=Low(:,1);
low=Low(:,2);
high=High(:,2);
plot(Time,low,'--*')
hold on
plot(Time,high,'--go')
xlabel(' Day of the months')
ylabel('Temperature in degree F')
title('September temperature data')
Projectile/New folder/LastName_BML1.m
%% MATLAB Exercise Bonus Challenge
% Program to calculate the maximum height and Time of flight from a initial
% height
% clear screen and data
clc
clear all
close all
disp('Program for Trajectories without Air Friction')
disp('-------------------------------------------------------------------')
% prompt user to input velocity,angle and initial height
v0=input('Enter the Initial Velocity: ');
theta=input('Enter the Initial Angle in Degree: ');
hi=input('Enter the Initial Height: ');
disp('-------------------------------------------------------------------')
% Evaluate the maximum height reached by the ball
% gravity
g=9.81;
Hmax = hi+(v0^2*sind(theta)^2)/(2*g);
% Evaluate the time the ball is in the air
T = ((v0*sind(theta))+sqrt((v0*sind(theta))^2+2*g*hi))/g;
% Display results
fprintf('The ball reaches a maximum height of %0.2f meters.\n',Hmax)
fprintf('The ball is in the air for %0.2f seconds.\n\n',T)
% Plot height versus time
% create time vector for 100 interval
t=linspace(0,T,100);
% y distance
y=hi+(v0*sind(theta).*t-0.5*g*t.^2);
figure;
plot(t,y,'-*b')
title(['Height Vs Time |',' Hmax=',num2str(Hmax),'m'])
xlabel('Time (sec)')
ylabel('Height (m)')
% Plot Height versus Distance
% x distance
x=v0*cos(theta).*t;
figure;
plot(x,y,'-or')
title(['Height Vs Distance |',' Range=',num2str(x(end)),'m'])
xlabel('Distance (m)')
ylabel('Height (m)')
Projectile/New folder/LastName_ML1.m
%% MATLAB Exercise
% Program to calculate the maximum height and Time of...