Project

pendulum

*********** Comments by Grader *********



The other thing that you can do is to attach the code and images in

projects.skill-lync.com and paste the link over here.

The animation you provided is not working.Please post it and post the link again here and then your assignment will be graded

Thank you.

Graded by : Mehul Shah

hi sir

in this simple pendulum program i have learnt lot about how it changes its location for various times

also a pendulum bob placed infront of thread is quiet interesting

i have upload my damping images and paste a link of my animation below

clear all
close all
clc
%inputs
b = 0.5;
g = 9.81;
l = 1;
m = 1;
%initial condition
theta_0 = [0;5];
%initial displacement=0,initial velocity=3rad/sec
%time points
t_span = linspace(0,20,200);
%solve ODE
[results] = lsode(\'odefunc\',theta_0,t_span);
%plotting
figure(1)
plot(t_span,results(:,1),\'color\',\'r\')
hold on
plot(t_span,results(:,2),\'color\',\'g\')
xlabel(\'time\')
ylabel(\'plot\')
legend(\'displacement\',\'velocity\')
x = results(:,1);
ct = 1;
for i=1:length(t_span)
    x0 = 0;
    y0 = 0;
    p = [(1*sin(x(i))),(-1*cos(x(i)))];
    figure(2)
    pause(0.03);
    plot([x0 p(1)],[y0 p(2)],\'linewidth\',2)
    hold on
    plot([-0.2 -0.2 0.2 0.2 -0.2],[-0.02 0 0 0.02 0.02],\'linewidth\',3)
    plot(x0,y0,\'-o\',\'linewidth\',2,\'color\',\'y\')
    plot(p(1),p(2),\'r.\',\'markersize\',70,\'linewidth\',3,\'color\',\'g\')
    hold off
    axis([-1 1 -1 0]);
    ct=ct+1;
    xlabel(\'time\')
    ylabel(\'displacement\')
    title(\'simple pendulum motion\')
    grid on
    text=sprintf(\"pendulum_damped_ode%05d.png\",ct);
    saveas(gca,text)
end
function [dtheta_dt] = odefunc(theta,t)
      b = 0.5;
      g = 9.81;
      l = 1;
      m = 1;
      theta1 = theta(1);
      theta2 = theta(2);
      dtheta1_dt = theta2;
      dtheta2_dt = -(b/m)*theta2-(g/l)*sin(theta1);
      dtheta_dt = [dtheta1_dt,dtheta2_dt];
end

https://youtu.be/Krswc29WMX0

https://projects.skill-lync.com/projects/simple-pendulum-motion-22332

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.