Sunday, June 6, 2010

Daylight Simulation in MATLAB 2008

By putting the source below to a M-File and compile it, you will see a virtual daylight on Figure window:
clear all
clc
clf
dt=linspace(0,pi,120);
for i=1:120
surfl(peaks)
shading interp;
for j=1:round(abs( sin(dt(i))*20))
light('Position',[cos(dt(i))*50 0 sin(dt(i))*10],'Style','infinite');
end
if i<20
title('Hello World')
elseif i>20 && i<50
title('Morning')
elseif i>50 && i<70
title('Noon')
elseif i>70 && i<100
title('Afternoon')
else
title('Evening')
end
m(i)=getframe();
end
title('Thats a simple day!')
movie(m,1,12)