Sea surface animation using random number and sine waveform in MATLAB
Code:
clc
clear
all
close
all
figure;
pause(5);
z=rand(1,100);
for i=1:100
if(rem(i,2)==0)
fill([-10 -10 10 10],[0 10 10 0],'k');
axis([-10
10 0 10]);
hold
on;
t=-10:0.01:10;
x=5-z(i)*abs(sin(t));
area(t,x);
else
fill([-10 -10 10 10],[0 10 10 0],'k');
axis([-10
10 0 10]);
hold
on;
t=-10:0.01:10;
x=5-z(i)*abs(sin(t+pi/2));
area(t,x);
end
pause(0.4);
clf
end
No comments