Few Simulation/Animation programs

By Nasser Abbasi

Last updated 10/10/2009

 

This page will contain Matlab scripts/functions and Mathematica notebooks that I am working on or done relating to simulation and animation.

 

I will list these in a table, with a small description of what each script or function does.

 

#

description

Link to source code

Screen shot

Animation wav file

0

Moving circle and cycloid

here

 

 

1

RANDOM WALK 3D

Matlab 7.1

 

This is a matlab script called

nma_random_walk_3d.m it is a simulation of random walk in 3D.

 

nma_random_walk_3d.m

nma_random_walk_3d.m.txt

 

There are 6 probabilities one for each direction (left x, rightx, left y, right y, up and down). Adjust the parameters at  the top of the script. See top of script for more information.

nma_random_walk_3d.avi

2

RANDOM WALK 2D

Matlab 7.1

 

This is a matlab script called

nma_random_walk_2d.m it is a simulation of random walk in 2D.  

 

nma_random_walk_2d.m

nma_random_walk_2d.m.txt

 

There are 3 probabilities that can be assigned. one for right step, one for left step, and one for no step. See top of script for more information

 

 

This wav file shows animation with 3 equal probabilities for left, right and no step.

nma_random_walk_2d_equal_prob.avi

 

This wav file shows animation with probability of left step and right step being equal and each is 0.5. Hence no effect is taken for making no step during any time.

nma_random_walk_2d_left_and_right_only.avi

3

Ornstein-Ehrenfest

Mathematica 6.01

 

This is an animation of the solution to the PDE

Use adjusts ‘c’ and ‘D’ parameters and animation of solution is shown.

One version written in Matlab and another in Mathematica 6 (Using Manipulate)

Matlab source code:

OE_model.m  (script. Edit to change parameter values at top of script).

 

 

Mathematica source code

O_E.nb

Screen shots of Matlab animation

 

 

Mathematica screen shot

Wav files of Matlab animation

c_at_0.001_30_seconds.avi

c_at_0.01_25_seconds.avi

4

Einstein_Weiner

Mathematica 6.01

 

This is an animation of the solution to the PDE

In Mathematica. Adjust using the GUI the parameters beta (drift) and D (diffusion) and simulation time and run it.

Mathematica source code

E_W.nb

 

 

5

Bouncing Ball inside a square

Mathematica 6.01

 

Just a small animation of a ball bouncing between the walls inside a closed square. Shows how to use Mathematica to do animation. This was done without using Manipulate.

Mathematica source code

 

oneBouncingBall.nb

 

HTML

 

 

 

6

Bouncing Ball inside a square

Mathematica 6.01

 

This is the same as above, except this one uses Manipulate to specify the simulation parameters (time, radius of ball, speed of simulation, etc…). This is more flexible.

Source code  try1.nb

HTML

PDF

 

7

 

Markov chain transition probability Matirx being raised to Powers

 

Mathematica 6.01

A very small computation to show visually the P matrix (probability transition matrix) used in markov chains being raised to higher powers. To show to what value it converges to.  Move the slider and see the matrix being raised to that power one step at a time.

 

Source code mpower_v1.nb

HTML

 

 

8

Markov chain transition probability Matirx for inventory problem

 

Shows the P matrix for the inventory problem as number of weeks increases and the current state row vector. Select ‘s’ and ‘S’ and number of weeks from the GUI.

Source code mpower_v2.nb

HTML

 

9

Using simulink to look at response to a step input showing how to use a scope with multiple input signals

PDF