Create converging gratings in matlab
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposte (1)
VINAYAK LUHA
il 27 Set 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
0 Commenti
Vedere anche
Categorie
Scopri di più su Startup and Shutdown in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!