Challenge

Week 3 - Solving second order ODEs

pendulum parameters

b(damping co-efficient), g(gravity), m(mass), l(length)

Initial conditions - theta_0 = initial displacement of pendulum is zero and initial velocity is five.

Time points, we are intigrating the ode system to get a solution 't_span' is a time array it goes from 0 to 10 with 500 values.

Solve ODE(Ordinary differential equation), ode45 is inbuilt slover in matlab. t and theta are main inputs and they are dependent and independent variables of ode system,
ode_fun(t, theta, b, g, l, m) is the separate function, which is derived by mathematical expression.
t_span is a time a time array after that we provide the intial conditions.


plotting t, results where as we have two columns. so we have to take only column so we avoid row by using ':' operator. plot(t,results(:,1)) we are plotting 1 column values to plot.
hold on is used to represnt two plots in a single plot.
plot(t,results(:,1)) we are plotting 2 column values to plot.
'xlabel' is used to lable the x-axis in the plot. 'ylabel' is used to mention the y-axis.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.