%COherent State hcros -. 0 simulations 1
%Expression
clc
clear
%Variables and limits
L=1;
A=5;
z=0:0.001:L;
tmax=10000;
incr=.001;
n=1;
for t=1:incr:tmax
    n=1; % First normal mode
    v1=20;
    wlen=2*L/n;
    k1=2*pi/wlen;
    freq1=10*pi;
    f1=A*sin(k1.*z)*cos(freq1*t);
    
    n=2; %Second normal mode
    v2=10;
    wlen=2*L/n;
    k2=2*pi/wlen;
    freq2=20*pi;
    f2=A*sin(k2.*z)*cos(freq2*t);
    
    n=3; %Third normal mode
    v3=10;
    wlen=2*L/n;
    k3=2*pi/wlen;
    freq3=30*pi;
    f3=A*sin(k3.*z)*cos(freq3*t);
    
    %Superposition
    f=f1 + f2 + f3;
    
    subplot(2,2,1);
    plot(z,f1);
    axis([0 1 -15 15])
    title('Wave on String');
    xlabel('z->');
    ylabel('Wave Amplitude->');
    grid ON
    
    subplot(2,2,2);
    plot(z,f2);
    axis([0 1 -25 25])
    title('Wave on String');
    xlabel('z->');
    ylabel('Wave Amplitude->');
    grid ON
    
    subplot(2,2,3);
    plot(z,f3);
    axis([0 1 -15 15])
    title('Wave on String');
    xlabel('z->');
    ylabel('Wave Amplitude->');
    grid ON
    
    subplot(2,2,4);   
    plot(z,f);
    axis([0 1 -15 15])
    title('Wave on String');
    xlabel('z->');
    ylabel('Wave Amplitude->');
    grid ON
    
M(n) = getframe();
n=n+1;
end
fps=100;
repet=100
movie(M,repet,fps)
