% wave2d % usage: wave2d(m,n,k,l); % show real and imaginary parts of a pure 2d waveform % % m,n: number of rows and columns of the image matrix % k,l: vertical and horizontal frequencies % S. Allen Broughton - 23 Sep 2010 function wave2d(m,n,k,l); tm = (0:1:(m-1))/m; % vertical sampletimes tn = (0:1:(n-1))/n; % horizontal sampletimes % define wave i = sqrt(-1); wave = exp(2*pi*i*k*tm')*exp(2*pi*i*l*tn); rwave = real(wave); iwave = imag(wave); % display results as images subplot(2,2,1); imagesc(rwave) title('real part'); subplot(2,2,2) imagesc(iwave) title('imaginary part') % display results as 3D plots subplot(2,2,3); mesh(rwave); axis([0,m-1,0,n-1,-1,1]); title('real part'); subplot(2,2,4) mesh(iwave); axis([0,m-1,0,n-1,-1,1]); colormap(gray) title('imaginary part')