Posts

Showing posts from July, 2012

Coarse Grained Movies in MATLAB

AIM : Let say the aim is to prepare a movie of coarse grained description of the system. In this example the 2-dimensionl lattice has been divided into several sub-square lattices. Then depending on the order parameter values (average) in the sub-square lattices, the color has been chosen and finally each frame has been added using 'addframe'. clear all; close all; aviobj = avifile('box_movie.avi','compression','None'); aviobj.KeyFramePerSec = 1; fig = figure; fid = fopen('fort.214'); nbox = 25; nframes = 9900; for i = 1:1:nframes     A = fscanf(fid, '%g', [1 nbox]);     if (i < 3500) && (mod(i,5) == 0)     % Draw smaller boxes         xstart = 0;     ystart = 0;     xlen = 1;     ylen = 1;         rectangle('position', [xstart, ystart, xlen, ylen]);     nx = floor(sqrt(nbox));     ny = nx;     dx = xlen/(nx);     dy = ylen/(ny);     count = 0;     for i = 1:nx         x = xstart + (i-1)*dx;         for j = 1:ny    

Movies in Matlab: Addframe

2D movie of different types of particles, using 'gscatter' and 'addframe': MATLAB Let say, the goal is to create a movie file from different snapshots and the available raw data has the co-ordinates and corresponding order parameters value. By the following way one will end up with a 2D video of (x,y) data having different types of particles characterized by 'z' values. The two key commands used are gscatter and addframe . In this example all the particles are of two types, so I used two types of color function (blue and red) to distinguish them. Finally, I was looking to fill up the markers, however I could not find any suitable way to fill them (If anybody knows about it please let me know). Instead of searching for filling the markers I used a crude way of increasing linewidth of the markers, which eventually ended up, what I needed :).   %To create movie from scatter plot aviobj = avifile('movie.avi','compression','None'); fig=fi