I am trying to show the propogation of this wave using matla

I am trying to show the propogation of this wave using matlab but i cannot get it to work properly. please only answer if you manage to show the wave animation correctly. here\'s my code:

% show the animation of the wave
clear;
x=0:0.0005:1; % 1 meter space, resolution of image is 0.0005
t= 0:0.1:100; % total period of time, resolution of time is 0.1 second
period = 10; % period
wavelength = 0.30 % wavelength
A = 1; % amplitude

figure(1);
for ctime = t
wave_1 = exp(-((2*x-3*t)^2)/4)-exp(-((2*x+3*t-10)^2)/4);
plot(x, wave_1,\'b\');

pause(0.025);
end

Solution

i didnt get the presence of period, wavelength and amplitude in code.

and in function wave_1, (2*x-3*t),here x and t should be of same order.

if youhave matlab2014b then code could be,

x=0:0.0005:1;
t= 0:0.0005:1;

wave_1 = exp(-((2*x-3*t)^2)/4)-exp(-((2*x+3*t-10)^2)/4);

for i=length(x)

addpoints(curvex(i),wave_1(i));

drawnow

end

if your matlab is prior to 2014, then code should be ,

x=0:0.0005:1; % 1 meter space, resolution of image is 0.0005
t= 0:0.0005:1; % total period of time, resolution of time is 0.1 second
period = 10; % period
wavelength = 0.30 % wavelength
A = 1; % amplitude
fig=figure(1);
for i=length(x)
wave_1 = exp(-((2*x-3*t).^2)/4)-exp(-((2*x+3*t-10).^2)/4);
plot(x, wave_1,\'b\');
comet(x,wave_1)
  end

I am trying to show the propogation of this wave using matlab but i cannot get it to work properly. please only answer if you manage to show the wave animation

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site