random generation of fractions

6 views (last 30 days)
Anwesha
Anwesha on 13 Aug 2018
Commented: Anwesha on 14 Aug 2018
Hello, I have fractions such as 1/720,1/360,1/90. How do i randomise them? these numbers are the spatial frequencies which are in cycles/pixel(by default in psychtoolbox). I would like to have a grating with many spatial frequencies generated randomly. Appreciate any help. Thanks Anwesha

Answers (1)

KSSV
KSSV on 13 Aug 2018
a = 90;
b = 720;
r = (b-a).*rand(100,1) + a;
F = 1./r
  11 Comments
Anwesha
Anwesha on 14 Aug 2018
msize = numel(Fr); for a = 1:msize freq1= Fr(randperm(msize,1));
Screen('DrawTextu re', window, gratingtex, [], [], angle, [], [], [], [], rotateMode, [phase, freq1, amplitude, 0]);
Screen('FillRect', window, [1,1,1],spotRect);
vbl = Screen('Flip', window, vbl + 0.5 * ifi);
end
Anwesha
Anwesha on 14 Aug 2018
This is the part of the code where I made the changes..not able to figure out what is going wrong

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!