Message Boards Message Boards

Pendulum with friction

Posted 1 year ago

Hi, do you know why this code is not working?

Manipulate[
 Module[{dt, n, t, theta, omega, thetaData}, 
  dt = 0.01;(*Tamaño del paso de tiempo*)
  n = 2000;(*Número de pasos de tiempo*)t = Table[i*dt, {i, 0, n}];
  thetaData = {theta0};
  theta = theta0;(*Inicializar theta*)
  omega = 0;(*Inicializar omega*)(*Simulación del movimiento del \
péndulo*)Do[omega = omega - (g/l)*Sin[theta] - rozamiento*omega*dt;
   theta = theta + omega*dt;
   thetaData = Append[thetaData, theta], {i, 1, n}];
  (*Gráfico del péndulo*)
  Graphics[{Line[{{0, 
       0}, {l*Sin[thetaData[[r]]], -l*Cos[thetaData[[r]]]}}], {Red, 
     Disk[{0, 0}, 0.03]}, {Black, 
     Disk[{l*Sin[thetaData[[r]]], -l*Cos[thetaData[[r]]]}, 
      0.1 Power[(30 m)/(4 \[Pi]), (3)^-1]]}}, 
   PlotRange -> {{-3.4, 3.4}, {-3.4, 0.5}}, 
   ImageSize -> {250, 250}]], {{theta0, \[Pi]/3., 
   "Ángulo inicial \[Theta](0)"}, \[Pi]/16., \[Pi]/2., 
  Appearance -> "Labeled"}, Delimiter, {{m, 4, "Masa m"}, 1, 15, 0.01,
   Appearance -> "Labeled"}, {{l, 2.25, "Longitud L"}, 1, 3, 0.01, 
  Appearance -> "Labeled"}, {{rozamiento, 0, "Fuerza de Rozamiento"}, 
  0, 1, 0.01, Appearance -> "Labeled"}, {{r, 1, "Controles"}, 1, 2001,
   1, ControlType -> Slider}, 
 TrackedSymbols :> {theta0, m, l, rozamiento, r}]
POSTED BY: Mituan Gonzper

The variable g is not given a numeric value.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract