【问题标题】:How do I use the screenRect function in MATLAB correctly?如何在 MATLAB 中正确使用 screenRect 函数?
【发布时间】:2020-08-14 16:18:37
【问题描述】:

当我试图在屏幕上的随机位置显示数字时,我运行以下代码:

% Screen parameters
center = [screenRect(3)/2 screenRect(4)/2)];
[mainwin, screenRect] = Screen(0, 'OpenWindow');

% potential locations to place sequences
nrow = 6; ncolumn = 6; cellsize = 100;
for ncells = 1:nrow*ncolumn
    xnum = (mod(ncells-1, ncolumn)+1)-3.5;
    ynum = ceil(ncells/nrow)-3.5;
    cellcenter(ncells,1) = center(1)+xnum.*cellsize;
    cellcenter(ncells,2) = center(2)+ynum.*cellsize;
end

% randomise position of numbers
cellindex = Shuffle(1:nrow*ncolumn); % randomize the position of the sequences within the grid specified earlier
     itemloc = [cellcenter(cellindex(1),1)-cellsize/2, cellcenter(cellindex(1),2)-cellsize/2, cellcenter(cellindex(1),1)+cellsiz

我收到以下错误:

Unrecognized function or variable 'screenRect'.

Error in First_draft (line 4)
center = [screenRect(3)/2 screenRect(4)/2];

【问题讨论】:

    标签: matlab psychtoolbox


    【解决方案1】:

    如果你确定你正确安装了toolbox,那么

      1. 使用Screen 方法返回screenRect 变量。
      • [mainwin, screenRect] = Screen(0, 'OpenWindow');
        
      1. 然后使用screenRectvariable
      • center = [screenRect(3)/2 screenRect(4)/2];
        

      ```

    【讨论】:

    • 它似乎无法识别“screenRect”变量。我跳过了工具箱安装过程的安装 Subversion 步骤。这能解释问题吗?否则,我下载了链接并将“DownloadToolbox”插入到似乎可以工作的命令窗口中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-03
    • 1970-01-01
    • 2014-01-06
    • 1970-01-01
    • 2017-08-19
    • 2015-12-14
    • 1970-01-01
    相关资源
    最近更新 更多