## Script that simulates a traveling wave on an nonrealistic string.
##The one end of the string is driven sinusoidally
## while the other end is kept fixed.
dx=1e-2; ## increment in horizontal displacement(m)
c=300; ## speed of the wave (m/s)
dt=dx/c; ## Increment in time (s)
r=c*dt/dx; ## Ratio of speed of wave to
## the speed of the string
## Initial profile
x=-1:dx:1;
y=zeros(size(x)); ## Change the gaussian distribution
## to get zero vertical
##displacements for all parts of
##the string.(purely flat initially)
plot(x,y)
pause
##For the sinusoidally driven end, given constans are:
A=0.5; ##amplitude(m)
rate=100; ## inverse of the period (cycles/s)
omega=2*pi*rate ; ## angular frequency(Radians/s)
## Time boundary conditions. Get previous and
## present displacement as initial profile
ynow=y;
yprev=y;
Nsteps=2000;
## all steps are the same for the loop as the string_fixed
## apart from the function ynext
for n=1:Nsteps
ynext=propagate_driven(ynow,yprev,r,omega,A,n,dt);
plot(x,ynext,';;')
axis([-1.05,1.05,-1.1,1.1])
pause(0);
yprev=ynow;
ynow=ynext;
endfor
Comments
Post a Comment