Create converging gratings in matlab
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
VINAYAK LUHA
2023 年 9 月 27 日
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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!