Tuesday, 2 April 2013

Propagating Wave, Standing Wave and Attenuated Wave in MATLAB



WAVE


Consider a traveling transverse wave on a string. Consider the string to have a single spatial dimension. Consider this wave as traveling
  • in the x direction in space. E.g., let the positive x direction be to the right, and the negative x direction be to the left.
  • with constant velocity v, where v is
    • independent of wavelength 
    • independent of amplitude 

This wave can then be described by the two-dimensional functions
u(x, \ t) = F(x - v \ t) (waveform F traveling to the right)
u(x, \ t) = G(x + v \ t) (waveform G traveling to the left)
more generally, by

u(x,t)=F(x-vt)+G(x+vt). \,
representing two component wave forms F and G traveling through the medium in opposite directions. A generalized representation of this wave can be obtained as the partial differential equation
\frac{1}{v^2}\frac{\partial^2 u}{\partial t^2}=\frac{\partial^2 u}{\partial x^2}. \,




These waves has always been problem while studying such theories. Let you all guys have practical experience of waves with MATLAB. 

Propagating Wave:


k = 5;
w = 5;
dx = 0.05;
x = 0:dx:4;
dt = 0.05;
t = 1:dt:10;
A = 1;

for j=1:length(t)
    
    for i=1:length(x)
        
        y(j) = A * sin(k.* x(i) - w.*t(j));        
    end
    
    pause (0.1)
    plot(y)
    axis([1,100,-2,2])
    grid
    
end

Standing Wave: 


k = 5;
w = 5;
dx = 0.05;
x = 0:dx:4;
dt = 0.05;
t = 1:dt:10;
A = 1;

for j=1:length(t)
    
    for i=1:length(x)
        
        y(i) = A * sin(k.* x(i)).* cos(w.*t(j));        
    end
    
    pause (0.1)
    plot(y)
   axis([1,100,-2,2])
    grid
    
end

Attenuated Wave:


k = 5;
w = 5;
dx = 0.05;
x = 0:dx:4;
dt = 0.05;
t = 1:dt:10;
A = 6;

for j=1:length(t)
    
    for i=1:length(x)
        
        y(i) = A* exp(-t(j)) * sin(k.* x(i) - w.*t(j));        
    end
    
    pause (0.1)
    plot(y)
    axis([1,100,-2,2])
    grid
    
end

Let you try all these codes in MATLAB to get the feeling of wave.