On this π day 2024, I decided to tag along with Mike Croucher from The MATLAB Blog and show one way to compute π. The Model
I used Motion Actuation to roll the cylinder by 360 degrees and sensed by how much it had translated. I was then able to compute π using:
where d is the distance travelled and r is the radius of the cylinder.
in = Simulink.SimulationInput(mdl);
r = 1; % Cylinder radius;
d = out.yout{1}.Values.Data(end); % final distance
Because the cylinder slipped a bit on the ground, I did not get a very accurate result, but it's probably representative of the result you would get if you had tried computing π that way a few thousand years ago.
Now it's your turn
Hopefully, you can find more accurate ways to compute π.
If you need to model cylinders rolling on the ground, try opening the model used for this blog post in MATLAB Online by clicking on this banner:
Comments
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.