Week 3 - Solving second order ODEs
clear all
close all
clc
%inputs
l = 1
m = 1
b = 0.05
g = 9.81
%initial condition
theta_0 = [0;3]
%time point
t_span = linspace(0,20,100)
%solving ode
[t,results] = ode45(@(t,theta) ODE_func(t,theta,b,m,l,g),t_span,theta_0);
figure(1)
plot(t,results(:,1))
hold on
plot(t,results(:,2))
xlabel('plot')
ylabel('temp')
title('simplysupported_beem')
%animation
ct = 1;
figure(2)
theta_1 = results(:,1)
for i = 1:length(theta_1)
x0 = 0;
y0 = 0;
theta_2 = theta_1(i);
x1 = l*sin(theta_2);
y1 = -l*cos(theta_2)
plot([-2 2],[0 0])
hold on
plot([x0 x1],[y0 y1],'LineWidth',3)
plot( x1,y1,'marker','o','Color','r','MarkerSize',40,'MarkerFaceColor','y');
axis([-2 2 -2 2])
pause(0.03)
M(ct) = getframe(gcf)
hold off
ct = ct+1
end
movie(M)
videofile = VideoWriter('simplysupported_beem.avi','Uncompressed AVI');
open(videofile)
writeVideo(videofile,M)
close(videofile)
Explaination:-
Aim :-
TO stimulate to solving second order Odes and will get the position of the pendulum as a function of time.and we achive tha simply supported beem
Governing equation if :-
- It soluving seconder order ode equation it based on time and results
- [t,results] = ode45(@(t,theta) ODE_func(t,theta,b,m,l,g),t_span,theta_0);
- In that ODE_funcion was solve tha new file and merge the seconder order odes file
Objective of tha project :-
- In the main objective of the project is to achive tha second order odes at simply supported pendulam
- The work flow of the project is that bob was move on one side to another side
- In the code is plot( x1,y1,'marker','o','Color','r','MarkerSize',40,'MarkerFaceColor','y')
Body of the contant :-
*In case of programming project
- It was used to matlab programming language
- And it was take tha input perameter of tha pendulam like b,m,l,g
- b,m, l,g is nothing but b is damping coefficient and m is mass and l is length and g is gravity
- And let we take initial condition of tha pendulam like theta_0 = [0;3] and take time point is t_span = linspace(0,20,100)
- let tha solving tha second order ode to paste on the main program
- [t,results] = ode45(@(t,theta) ODE_func(t,theta,b,m,l,g),t_span,theta_0);
- Make a plot at time and result on both (:,1) and (:,2)
- And let we take tha xlabel and ylabel and title to clear output comes
* In case of simulation project :-
- Let we take tha animation command start with counter ct
- Now make the simply supported beem to take tha input perameter like theta_1 = (:,1)
- And using for loop command to make tha animation to using tha inputs
- Let we assume the orrigin x0 and y0 to x1 and y1 it first x0 = 0 and y0 = 0 and x1 = l*sin(theta_2) and y1 = -l*cos(theta_2)
- And plot tha straight line take tha point at [-2 2] and [0,0] it hold on
- It will be join the link at downwards at assume tha point at x1 and y1
- And we assume tha pendulam of bob used a markar command and tha circle it assume at 'o'
- make the plot at animate the simply supported beem
-
In plot( x1,y1,'marker','o','Color','r','MarkerSize',40,'MarkerFaceColor','y') and take tha axis [-2 2 -2 2]* In case of design project :-* finally use the movie command at full feel of animation of simply supported beem Movie(m)* videofile = VideoWriter('simplysupported_beem.avi','Uncompressed AVI');*At the movie command was use at open videofile and write video and close videofileConclution:-* final conclution at simply supported beem using solving second order odes, in that second order odes was put the ODE_func in matlab sucessfully