% Plot addition of two sin waves and sum. % Standing Waves, Beats, dispersion. % See Kenyon p. 328 sec. 10.6.2 % Steven Sahyun Nov. 19, 2014 clf(); xmax = 20; x=0:0.01:xmax; ymax = 8; E01 = 2.5; E02 = 2.5; k1= 1; w1= 0.05; k2= 1; w2= -0.05; for t = 1:100 % % of period to animate; 25 = 1/4 period, 50 = 1/2 etc. E1 = E01*sin(k1*x-w1*t); E2 = E02*sin(k2*x-w2*t); Esum = E1+E2; plot(x, E1, x, E2, x, Esum); xlim([0, xmax]); ylim([-ymax, ymax]); group_v = (w2-w1)/(k2-k1); title(['Superposition of 2 EM Waves. v_g =' num2str(group_v)]); xlabel('Distance'); ylabel('E field'); legend('E1', 'E2', 'Combined'); %axis equal M(t) = getframe; end