MATLAB: Array dimensions must match for binary array op.

arrayMATLAB

%b
lake=imread('lake.tif');
lake_fft=fftshift(fft2(lake));
[M,N]=size(lake_fft);
lap_filt=zeros(M,N);
for i=1:M
for j=1:N
lap_filt(i,j)= -4*pi^2*((i-M/2)^2+(j-N/2)^2);
end
end
lake_fft=lake_fft.*lap_filt;
lake_reconstruct=ifft2(ifftshift(lake_fft));
figure(1)
subplot(1,2,1);imshow(lake);title('Original Image')
subplot(1,2,2);imshow(lake_reconstruct,[]);title('Laplace frequency')
Im getting the following errors:
Array dimensions must match for binary array op.
(line 12)
lake_fft=lake_fft.*lap_filt;
not sure what the problem is and how it can be solved
whos lakess
Name Size Bytes Class Attributes
lakess 512x512x2 524288 uint8

Best Answer

The code runs just find for me. I don't have 'lake.tif', but I don't think that should matter.
Try clearing your workspace or restarting MATLAB.