フィルターのクリア

Randomizing Shape and Location

6 ビュー (過去 30 日間)
Brett
Brett 2012 年 11 月 23 日
Hi Matlab community, I love you guys. I'm using psychtoolbox and I am trying to randomize four direction of an triangle in four different locations so that it 1) won't appear in same direction as any other triangle, 2) it won't appear in the same location as any other triangle.
Problem 1: If left triangle quadrant 4, then no other left triangles will appear and no other triangles will appear in the left quadrant.
colarray = [c1; c2; c3; c4];
colidx1 = randi(4,1,1);
colour1 = colarray(colidx1,:);
colidx2 = randi(4,1,1);
while ismember(colidx2, colidx1)
colidx2 = randi(4,1,1);
end
...
This will randomize the color between 4 different colors, and it works beautifully. So I know I can do the same thing for 1 feature, like direction. But I don't know how to do it for two features: direction and location.
Problem 2:
uptriangle = [50 0;0 -50;-50 0]+600
Screen('FillPoly', window, [255 255 0], uptriangle)
Screen('Flip',window);
This code creates an upwards facing triangle, but its location and its shape are defined by the same information - [50 0;0 -50;-50 0]+600. Is there anyway I can move its location without changing its shape? Maybe something like uptriangle = triangle + xyquandrant, triangle = [50 0;0 -50;-50 0], xyquadrant = [300,300]? If I cannot define its shape and location separately, I don't think I will be able to randomize them separately.
Please help,

採用された回答

Walter Roberson
Walter Roberson 2012 年 11 月 23 日
I do not understand about "direction" ?
Yes you can move an object without changing its shape:
triangle = [50 0;0 -50;-50 0];
xoffset = 350; %for example
yoffset = 192; %or example
shiftedtriangle = triangle + repmat([xoffset; yoffset], 1, 3]);
  4 件のコメント
Walter Roberson
Walter Roberson 2012 年 11 月 23 日
shiftedtriangle = triangle + repmat([xoffset, yoffset], 3, 1);
Brett
Brett 2012 年 11 月 23 日
You are the best Walter - works great!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTiming and presenting 2D and 3D stimuli についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by