Assinment 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Assignment: 1

1) Euler’s method. In mechanics, we often use Euler’s method to determine


themotion of an object given how the acceleration depends on the velocity and
position of an object. For example, we may know that the acceleration a(x, v) is
given as a(x, v) = −kx− cv. If we know the position x and the velocity v at a time t =
0: x(0) = x0 = 0 and v(0) = v0 = 1, we can use Euler’s method to find the position
and velocity after a small timestepΔt:
v1 = v(t0 + Δt) = v(t0) + a(v(t0), x(t0))Δt
x1= x(t0 + Δt) = x(t0) + v(t0)Δt)
v2 = v(t1 + Δt) = v(t1) + a(v(t1), x(t1))Δt
x2= x(t1 + Δt) = x(t1) + v(t1)Δt
and so on.We can therefore use this scheme to find the position x(t) and the
velocity v(t) as function of time at the discrete values ti= iΔtin time.
(a) Write a function acceleration(v,x,k,C) which returns the value of
a(x, v) = −kx− Cv.
(b) Write a script that calculates the first 100 values of x(ti ) and v(ti ) when k =
10,C = 5, and Δt= 0.01. Plot x(t), v(t), and a(t) as functions of time.
(c) What would you need to change to instead find x(t) and v(t) is the
accelerationwas given as a(v, x) = k sin(x) − Cv?

2(a) If acceleration value is given at different time interval, find the velocity using
discrete integration method.

I 0 1 2 3 4 5
ti(seconds) 0 0.1 0.2 0.3 0.4 0.5
ai ( m/s2) 0 1.43 2.8 4.13 5.6 7.21

(b) If the position of an object moving in x direction is defined by x(t)=36t 2+2t+2 ,


what will be the velocity of object at t=3 seconds.

(c) A car sits in an entrance ramp to a freeway, waiting for a break in traffic. The
driver sees a small gap between two vehicles and accelerates with constant
acceleration along the ramp onto the freeway. The car starts from rest, moves in a
straight line, and has a speed of 20 m/s when it reaches the end of the 120-m ramp.
What is the acceleration of the car?
3) Position and Velocity of a Ball If a stationary ball is released at a
height(h0=50m) above the surface of the Earth with a vertical velocity(v 0=10m/s) ,
the position and velocity of the ball as a function of time will be given by the
equations where g is the acceleration due to gravity ( 9.81), h is the height above
the surface of the Earth (assuming no air friction), and v is the vertical component
of velocity. Write a MATLAB program that prompts a user for the initial height of
the ball in meters and velocity of the ball in meters per second, and plots the height
and velocity as a function of time.Be sure to include proper labels in your plots.

4) The tangent function is defined as tan(θ)=sin(θ)/cos(θ) . This expression can be


evaluated to solve for the tangent as long as the magnitude of cos(θ) is not too near
to 0. (If cos(θ) is 0, evaluating the equation for tan willproduce the nonnumerical
value Inf.) Assume that θis given in degrees,and write the MATLAB statements to
evaluate tan as long as the magnitudeof cos(θ) is greater than or equal to 10^-20. If
the magnitude of cos(θ) isless than , write out an error message instead.

5) The cost of sending a package by an express delivery service is $15.00 for the
first two pounds, and $5.00 for each pound or fraction thereof over two pounds. If
the package weighs more than 70 pounds, a $15.00 excess weight surcharge is
added to the cost. No package over 100 pounds will be accepted. Write a program
that accepts the weight of a package in pounds and computes the cost of mailing
the package. Be sure to handle the case of overweight packages.

6) Suppose a ball is thrown upwards with initial velocity, u=2m/s. It also suffers air
resistance during its motion. Solve the problem in MATLAB to find the maximum
height attained by the ball. Given D=0.0245m-1. Also give the plots of
acceleration,velocity and position versus time in three separate subplots till the ball
attains maximum height.

7) The output power produced by rotating motor is given by:


𝑃 = 𝜏𝑖𝑛𝑑 𝜔𝑚
Where 𝜏𝑖𝑛𝑑 is the induced torque on the shaft in N-m.𝜔𝑚 is the rotational speed
of the shaft in rad/s and P is in Watts. Rotational speed of the shaft is given by
the following equation:
𝜔𝑚 = 188.5(1 − 𝑒 −0.2𝑡 ) 𝑟𝑎𝑑/𝑠
And induced torque on the shaft is given by:
𝜏𝑖𝑛𝑑 = 10𝑒 −0.2𝑡 𝑁. 𝑚
Plot the torque, speed and power supplied by the shaft versus time for 0 ≤ 𝑡 ≤
10. Label your plots properly.

8)Space shuttle launch. When the space shuttle is lifting off, the vertical positions
for the first 10 s in 1 s intervals are given as

t(s) 0 1 2 3 4 5 6 7 8 9
y(m) 0 15 60 135 240 375 540 735 960 1215

(a) Draw the motion diagram and the displacements for this motion.
(b) Use the motion diagram to find the average velocity as a function of time
afterlift-off.
(c) Use the motion diagram to find the average acceleration as a function of time
afterlift off.
9)write a script and plot for the following functions using subplot command
f=sin(x)/x,y=e-x2 ,z=x2-10x+15 where x  5  x  5

10) Find out the run time error in the following MATLAB programs.
(a) for i=1:2:6;
x(i)=i^2;
end
(b) x=[ 0 7 8.3 71 4] ;
y= [ 0 9 4 2; 4.5 1] ;
z=x+y;

(c ) t=0:0.1:1;
x=linspace(0,1,10);
plot(t,x) ;
11) Predict the outcome of following programs manually?
(a) clc; clear all; close all;
x=linspace(5,1,7);
i=1;
while(x(i)>2)
i=i+1;
end
i

(b) clc;clear all; close all;


x=zeros(1,4);
fori=1:4
x(i)=i+1;
end
i
plot(x);

You might also like