5.0

5.0 | 3 ratings Rate this file 8 Downloads (last 30 days) File Size: 1.29 KB File ID: #28870
image thumbnail

Matlab Animation Demo

by Kobi Nistel

 

28 Sep 2010 (Updated 30 Sep 2010)

A simple animation demonstration using drawnow.

| Watch this File

File Information
Description

A simple animation demonstration using drawnow.
trigonometric function generated background .

MATLAB release MATLAB 7.9 (R2009b)
Tags for This File  
Everyone's Tags
animation, demo, graphics
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
17 Nov 2010 Sherif

Very nice.

10 Oct 2010 Kobi Nistel

Very nice. I will upload some of my more interesting animations soon.

09 Oct 2010 Grzegorz Knor

I created a movie based on your code:
http://youtu.be/cK3rOnJN6UA

regards

29 Sep 2010 Grzegorz Knor

You can do it in more efficient way, without two FOR loops:
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

Updates
30 Sep 2010

use of mashgrid instead of loops

Contact us