Hi Mohini,
It is my understanding that you want to know the modifications required in your code to make your gratings converge towards the center.
Here is a modification which involves decreasing the spatial frequency of the square wave in your code by modifying its frequency parameter as shown below:
F = (x * (sf - i/2));
Here is the complete code for your reference:
sf = 100;
n = 50;
for i = 1:n
x = linspace(-pi, pi, 100);
sinewave = [];
sinewave = square((x * (sf - i/2)));
onematrix = ones(size(sinewave));
sinewave2D = onematrix' * sinewave;
colormap(gray);
imagesc(sinewave2D);
drawnow;
end
Hope this helps.
Regards,
Vinayak Luha
