Vous êtes sur la page 1sur 8

Assignment-1,2

Assignment 1: Write a MATLAB program of Finding local maxima and


minima.
It can be on following lines:
(In short you are suppose to write a code for the function 'extrema' given in the example below )
Consider the following artificial noisy data:

t= 0:pi/16:8*pi;
y = sin(t).*rand(size(t));
plot(t,y)

Now consider how easy it is to find the extrema with Carlos's EXTREMA function:

figure
plot(t,y)
[ymax,imax,ymin,imin] = extrema(y);
hold on
plot(t(imax),ymax,'r*',t(imin),ymin,'g*')

What about smoothing those data?


By the way, given a noisy source, it might also be nice to have a way to smooth the data. A quick search for SMOOTH in MATLAB's
help browser shows how to do that with the always-useful Curve Fitting Toolbox:
y2 = smooth(y,20);
figure
plot(t,y2)
[ymax2,imax2,ymin2,imin2] = extrema(y2);
hold on
plot(t(imax2),ymax2,'r*',t(imin2),ymin2,'g*')
hold off

Answer: The function extrema has been created in program folder.


COMMENTS:-Note that in the first graph the noisy signal is indicated which consists of unexpected noise
at certain points also here extremum points i.e maxima or minima are not indicated. In obtaining the
second graph we have used the carlos functioin or command which indicates extrema. Thus command
used here is EXTREMA which gives us red points (here maxima) and green points (here minima)
respectively but it is important to note that noise is not smoothened. So again in the third graph we
have used the command SMOOTH to smoothened the noise signals and obtain smooth curve also we
have obtained maxima and minima indicated by red & green points respectively.

Assignment 2:

Formulate and Solve Brachistochrone problem in MATLAB (Write MATLAB code)

Find the shape of the curve down which a bead sliding from rest and accelerated by gravity will slip
(without friction) from one point to another in the least time. The term derives from the Greek
(brachistos) "the shortest" and (chronos) "time, delay."
The brachistochrone problem was one of the earliest problems posed in the calculus of variations.
Newton was challenged to solve the problem in 1696, and did so the very next day (Boyer and Merzbach
1991, p. 405). In fact, the solution, which is a segment of a cycloid, was found by Leibniz, L'Hospital,
Newton, and the two Bernoullis. Johann Bernoulli solved the problem using the analogous one of
considering the path of light refracted by transparent layers of varying density (Mach 1893, Gardner
1984, Courant and Robbins 1996). Actually, Johann Bernoulli had originally found an incorrect proof that
the curve is a cycloid, and challenged his brother Jakob to find the required curve. When Jakob correctly
did so, Johann tried to substitute the proof for his own (Boyer and Merzbach 1991, p. 417).
In the solution, the bead may actually travel uphill along the cycloid for a distance, but the path is
nonetheless faster than a straight line (or any other line).
The time to travel from a point P1 to another point P2 is given by the integral

(1)
where is the arc length and is the speed. The speed at any point is given by a simple application of
conservation of energy equating kinetic energy to gravitational potential energy,

(2)
giving

(3)

Plugging this into (1) together with the identity

(4)

then gives
(5)

(6)

The function to be varied is thus

(7)

To proceed, one would normally have to apply the full-blown Euler-Lagrange

differential equation
(8)

However, the function

is particularly nice since

immediately use the Beltrami

does not appear explicitly. Therefore,

, and we can

identity
(9)

Computing

(10)

subtracting

from

, and simplifying then gives

(11)

Squaring both sides and rearranging slightly results in


(12)

(13)

where the square of the old constant


the parametric

has been expressed in terms of a new (positive) constant

. This equation is solved by

equations
(14)
(15)

which are--lo and behold--the equations of a cycloid.

If kinetic friction is included, the problem can also be solved analytically, although the solution is significantly messier. In that case,
terms corresponding to the normal component of weight and the normal component of the

acceleration (present because of

path curvature) must be included. Including both terms requires a constrained variational technique (Ashby et al. 1975), but
including the normal component of weight only gives an approximate solution. The tangent and normal

vectors are
(16)

(17)

gravity and friction are then


(18)
(19)
(20)

and the components along the curve are


(21)

(22)

so Newton's Second Law gives

(23)

But
(24)

(25)

(26)
(27)

so

(28)

Using the Euler-Lagrange

differential equation gives


(29)

This can be reduced to

(30)

Now letting

(31)

the solution is
(32)
(33

Source: http://mathworld.wolfram.com/BrachistochroneProblem.html
Figure depicting Brachistochrone Problem

Answer: The code for branchistocrone problem is saved in program folder.(plotsolution.m)

COMMENTS:- Given two points A and B in a vertical plane THROUGH MATLAB WE HAVE

FOUNDED the curve traced out by a point acted on only by gravity, which starts at A and
reaches B in the shortest time."In this example, we solve the problem numerically for A = (0,0)
and B = (10,-3), and an initial speed of zero.
THEN OBSERVE THE RESULTS FOR THE GRAPH FOR Y VERSUS X WHEN BEAD IS MOVING
DOWNWARDS OF THE PLANE GRAPH IS HYPERBOLIC DECREASING ONE AND WHEN WE ARE
TRYING TO TAKE IT UP BY EXPENDITURE OF ENERGY THEN IT IS HYPERBOLIC UP. SIMILARLY WE
CAN PLOTS OTHER GRAPHS BETWEEN THETA I.E ANGLE MADE BY VERTICAL WRT TO TIME AND
THETA W.R.T TO VELOCITY RESPECTIVELY.

Reference: http://www.scientificchess.com/articles/MittalNumerical%20Solution%20to%20the%20Brachistochrone%20Problem.pdf

Vous aimerez peut-être aussi