Create converging gratings in matlab

1 Ansicht (letzte 30 Tage)
Mohini Sengupta
Mohini Sengupta am 12 Apr. 2022
Beantwortet: VINAYAK LUHA am 27 Sep. 2023
I have created square gratings and can move them left or right with the following code. However I want to move the grating in a converging direction that is both sides, left and right more towards the center. How can I modify the code to do that?
sf=6;
n=50;
for i=1:n
x=linspace(-pi, pi, 100);
sinewave=[];
sinewave=square((x*sf)+i); % -i for the other direction
onematrix=ones(size(sinewave));
sinewave2D=(onematrix' * sinewave);
colormap(gray);
imagesc(sinewave2D);
drawnow;
end
Thanks

Antworten (1)

VINAYAK LUHA
VINAYAK LUHA am 27 Sep. 2023
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

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by