Linux, Matlab, Python, Android, Latex
Pages
Home
About me
Contact with Me
C and C++ Archive
Site Map
Showing posts with label
a travelling wave by making animation in matlab
.
Show all posts
Showing posts with label
a travelling wave by making animation in matlab
.
Show all posts
Saturday, August 10, 2013
A Traveling Wave by Making an Animation in MATLAB
clc %clears the command window
clear %clears variables
%Variables:
%Eo wave amplitude (V/m)
%f frequency (Hz)
%omega angular frequency (rad/s)
%t time snapshot
%c speed of light
%z position
%E Electric Field Intensity
%B phase constant (1/m)
%phi phase constant (s)
%phir phase constant (radians)
%lambda wavelength
(m)
%Initial Values of Variables:
f=1000;
phi=0;
c=2.998e8;
lambda=c/f;
t=1;
phir=phi*pi/180;
Eo=1;
B=2*pi/lambda;
omega=2*pi*f;
z=0:4*lambda/100:4*lambda;
E=Eo*cos(omega*t-B*z+phir);
plot(z,E)
axis([0 4*lambda -2*Eo 2*Eo])
grid
xlabel('z(m)')
ylabel('E(V/m)')
pause
t=0:1/(40*f):1/f;
for n=1:40;
E=Eo*cos(omega*t(n)-B*z+phir);
plot(z,E)
axis([0 4*lambda -2*Eo 2*Eo])
grid
title('General Wave Equation');
xlabel('z(m)');
ylabel('E(V/m)');
M(:,1)=getframe;
end
After that I run it from the command window. I give three figures these are in different time to
see properly the wave is travelling.
Read More
Subscribe to:
Posts (Atom)