?? ball_position_velocity.m
字號:
% Script file: ball_position_velocity.m
%
% Purpose:
% To plot the height and velocity of a ball
% the position and velocity of the ball as a function of time
% will be given by the equations h(t)=1/2*g*t^2+vo*t+ho,v(t)=g*t+vo
%
% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 09/03/07 Jane Original code
%
% Define variables:
% ho -- a initial height above the surface of the Earth at which a
% stationary ball is released(m)
% vo -- a initial velocity (m/s)
% t -- time variable
% h_t -- height above the surface of the Earth (assuming no air
% friction)(m)
% v_t -- the vertical component of velocity(m/s)
% g -- the acceleration due to gravity(-9.81m/s^2)
% set the acceleration due to gravity
g=-9.81;
% prompts a user for the initial height of the ball in meters and velocity
% of the ball in meters per second
ho = input('Enter the initial height of the ball in meters:\n' );
vo = input('Enter the initial velocity of the ball in meters per second:\n' );
% Create an array of time variable
t = 0:.01:5;
% Calculate the height above the surface of the Earth
h_t=1/2*g*t.^2+vo*t+ho;
% Calculate the vertical component of velocity
v_t=g*t+vo;
% plot the height and velocity as a function of time
subplot(211)
plot(t,h_t);
title('Plot of height versus time');
xlabel('t(m)');
ylabel('h(t)=1/2gt^{2}+v_{o}t+h_{o}');
subplot(212)
plot(t,v_t);
title('Plot of velocity versus time');
xlabel('t(m/s)');
ylabel('v(t)=gt+v_{o}');
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -