image thumbnail
from Matlab Animation Demo by Kobi Nistel
A simple animation demonstration using drawnow.

anidemo.m
clear all 
close all 
clc

sx = 100; 
sy = 100;

imr = zeros(sx,sy,3); 
im = zeros(sx,sy,3); 
im2 = zeros(sx,sy,3);

[xx yy]=meshgrid(1:sx,1:sy); 
for time =1:500 
    z = (2+ cos(time /100)); 
     
    x = xx/z+cos(time/100)*50; 
    y = yy/z+sin(time/100)*50; 
    x2 = xx/z+sin(time/40)*50; 
    y2 = yy/z+cos(time/51)*50; 
    x3 = xx/z+sin(time/65)*50; 
    y3 = yy/z+cos(time/37)*50; 
     
    im2(:,:,1)=abs((cos(x/10)+cos(y/10)))/2; 
    im2(:,:,2)=abs((sin(x2/10)+cos(y2/10)))/2; 
    im2(:,:,3)=abs((cos(x2/10)+sin(y2/10)))/2; 
    im(:,:,1)=abs(0.5+(sin(x./(sin(y/10)*5+10)+y./(cos(x/10)*5+10))+sin((320-x)./(sin(y/10)*5+10)+(199-y)./(cos(x/10)*5+10)))/4); 
    im(:,:,2)=abs(0.5+(sin(x3./(sin(y3/10)*5+10)+y3./(cos(x3/10)*5+10))+sin((320-x3)./(sin(y3/10)*5+10)+(199-y3)./(cos(x3/10)*5+10)))/4); 
    im(:,:,3)=abs(0.5+(sin(x2./(sin(y/10)*5+10)+y./(cos(x2/10)*5+10))+sin((320-x2)./(sin(y/10)*5+10)+(199-y)./(cos(x2/10)*5+10)))/4);     
    imr = im.*0.6 + im2.*0.4; 
    
    image(imr); 
    drawnow; 
end

Contact us