Construction of the wave equation
I was trying to plot a flat wave equation in Matlab. I am trying to plot the real part $ (1 / R) E ^ i (kR + wT) $ i. $ (1 / R) cos (kR + wT) $. So I used the following code in Matlab (for one point like t = 5),
x=-5:0.1:5; y=-5:0.1:5; t=5; w=1.3; k=1.3; [X,Y]=meshgrid(x,y); R=(X.^2+Y.^2)^1/2; u=20*cos(k*R+w*t); surf(X,Y,u);
When I run this code, I get the following sketchy graph: It looks fine, I think, as I would expect. But if I increase the wavenumber and angular to 15 I get this: It seems to be an interference pattern, but I have no idea why I am getting this because I have not used interference effects. Can anyone explain what is going on here?
What I'm really trying to do is plot a radially moving wave function (on a surface, like a water surface) for demonstration in my class. How can I turn this into an animation that shows waves of waves moving from a point source?
thanks for the help
source to share
You see an alias that is caused by undersampling. This alias has (at least) two possible reasons :
- The sampling of the function defined by the grid of x, y values ββis insufficient.
- Matlab plots a graph on a shape with a limited number of screen pixels. Graphics rendering involves some downsampling if the matrix to be rendered is large compared to the number of pixels in the drawing. This downsampling process may introduce aliasing.
As for the first type of aliases : when you increase the wavenumber, the wave changes faster in the x and y directions. Thus, for the correct visualization of the function, it is necessary to shorten the sampling period by the same proportion.
This is your original code, only with k=15
and w=15
; and surf
replaced with imagesc
for clarity (the picture is similar to yours, but seen "from above"):
x=-5:0.1:5; y=-5:0.1:5; t=5; w=15; k=15; [X,Y]=meshgrid(x,y); R=(X.^2+Y.^2)^1/2; u=20*cos(k*R+w*t); imagesc(x,y,u);
The resulting shape demonstrates anti-aliasing artifacts:
Now using more precise sampling
x=-5:0.01:5; %// note: 0.01: finer grid y=-5:0.01:5; t=5; w=15; k=15; [X,Y]=meshgrid(x,y); R=(X.^2+Y.^2)^1/2; u=20*cos(k*R+w*t); imagesc(x,y,u);
reduces the first type of aliases. However, some artifacts are still visible in the figure:
This is probably caused by the second type of aliases mentioned above. To confirm this, I have run the same code in Matlab R2014b, which better avoids imposing aliases caused by the graphics rendering (note also that in this version of Matlab was changed color map by default). You can see that the results are better compared to the previous figure:
Bottom line: use a finer sampling and move to Matlab R2014b if possible .
source to share