微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在MATLAB中正确使用screenRect函数?

如何解决如何在MATLAB中正确使用screenRect函数?

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

% 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,1)+cellsiz

我收到以下错误

Unrecognized function or variable 'screenRect'.

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

解决方法

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

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

````

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。