Here's a cool pulley simulation I made visualised on Matlab:
I'm learning to animate simulations on Matlab. So, I decided to animate one of my coolest problems, Simulating Dynamics2
The actual simulation was done with the help of Karan Chatrath's code solution to my problem. I modified the code to make it more efficient and added some extra features, and more importantly writing the second part of the code, which was animating the data.
The setup above is basically two masses connected by a pulley, with the second mass dragging the first mass with the help of gravity. There is friction between the first mass and the floor.
The equations of motion can be derived using Newton's Laws, here's the system in matrix form:
$\begin{bmatrix} m_1 & 0 & \mu & \cos(\theta) \\ 0 & m_2 & 0 & 1 \\ 0 & 0 & 1 & \sin(\theta)\\ 2x & 282y & 0 & 0 \end{bmatrix}$ $\begin{bmatrix} \ddot{x} \\ \ddot{y} \\ N \\ T \end{bmatrix} = \begin{bmatrix} 0 \\ m_2 g \\ m_1g \\ 2\dot{x}^2 + 2\dot{y}^2 \end{bmatrix}$
We can solve for these values simply by multiplying the inverse system matrix by the vector on the right hand side. Once we do this, we have to numerically integrate $\ddot{x},\ddot{y}$, the first and second indices of the solution to $A^{1}b$.
For the animation, just draw two squares with the tops at the position of the point masses at x coordinate for the first mass $x$ and y coordinate for the second mass $y$. Then draw lines from the hinge to each mass.
To maintain accuracy, I added a counter to add the values of time, $x$, and (y) to arrays. The animation works by while looping through these arrays, drawing the data, deleting the data, and redrawing through the loops.
The values I used for the simulation are $m_1 = 3, m_2 = 2, g = 10, \mu = 0.8, l = 14m$
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 

Have a try for yourself, or, if you don't have Matlab, take a look at the GIF above.
Easy Math Editor
This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.
When posting on Brilliant:
*italics*
or_italics_
**bold**
or__bold__
paragraph 1
paragraph 2
[example link](https://brilliant.org)
> This is a quote
\(
...\)
or\[
...\]
to ensure proper formatting.2 \times 3
2^{34}
a_{i1}
\frac{2}{3}
\sqrt{2}
\sum_{i=1}^3
\sin \theta
\boxed{123}
Comments
Sort by:
Top Newest@Percy Jackson
@NSCS 747
In case you're interested. I couldn't get Karan Chatrath or Steven Chase's tag though lol.
@Talulah Riley If you're active anymore.
Log in to reply
Nice bro! Your mentions are all wrong. I didn't get the notif as they're not blue. I can mention them for you though  @NSCS 747, @Talulah Riley, @Karan Chatrath, @Steven Chase
Log in to reply
Yeah; I may have edited the comment. When you edit comments, all your mentions go away. Btw thanks a lot for adding them back :)
Log in to reply
Log in to reply
Impressive work
Log in to reply
Thanks. Seeing it visualised adds a level of cool to simulations.
Log in to reply