Question

Find an approximate solution to the pendulum problem such that d2 theta /dt2 +g/l theta =...

Find an approximate solution to the pendulum problem such that d2 theta /dt2 +g/l theta = 0.    Use an approximate solver in matlab to find the solution to the exact equation d2 theta/dt2 +g/l * sin( theta) = 0. Compare the two solutions when the initial angle is 10, 30, and 90. Find a way to quantify the difference.

One approximate method for solving differential equations is Runge-Kutta, which in Matlab goes by the name ode45. I have made a template of how to solve a differential equation in matlab using ode45. Note that these are two separate files: Equations.m (the function that contains the differential equations) and Driving_Script2.m (the script that drives the solver).

Make 3 plots, with each plot showing the exact and approximate solution for each of the three angles. (The command "subplot" will make multiple plots on a single page. You will see that the exact and approximate solution are different. What I want you to do is to quantify how different the solutions are. Also, remember that matlab uses radians...(2*pi/360 * angle).

Template for solving a differential equation using ode45 in matlab:

% Driving_Script2.m (You can change the name)

clear all;

close all;

tspan = [0 10] ; Interval to be solved

y0 =     [1.0 0]     ; %initial condition here ...the first is angle, the second is velocity

% specify the equations to be solved using the approximate solver within the function Equations.m

[t,y] = ode45('Equations',tspan,y0)

figure(100)

h1=plot(t, y(:,1))

% Equations.m

function dy = Equations(t,y)

g= 9.81, l=2; % Constants here

%

dy = zeros(2,1);

dy(1) = y(2);

dy(2) = -g/l*sin(y(1));

%

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

clc;
clear all;
close all;
g=9.81;
l=2;
f=@(t,th) [th(2);-(g*th(1))/l];
g=@(t,th) [th(2);-(g*sind(th(1)))/l];
tspan=[0 30];
y0=[30 0];
[t1,th1]=ode45(f,tspan,y0);
[t2,th2]=ode45(g,tspan,y0);

tspan=[0 30];
y0=[90 0];
[t3,th3]=ode45(f,tspan,y0);
[t4,th4]=ode45(g,tspan,y0);

tspan=[0 30];
y0=[10 0];
[t5,th5]=ode45(f,tspan,y0);
[t6,th6]=ode45(g,tspan,y0);

subplot(3,1,1)
plot(t1,th1(:,1),t2,th2(:,1),'r');
subplot(3,1,2)
plot(t3,th3(:,1),t4,th4(:,1),'r');
subplot(3,1,3)
plot(t5,th5(:,1),t6,th6(:,1),'r');

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Find an approximate solution to the pendulum problem such that d2 theta /dt2 +g/l theta =...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT