arrays - 如何将单元格数组中的字符读取到 psychtoolbox 屏幕上
问题描述
我正在设置一个实验,其中成对的单词会以随机顺序闪烁到屏幕上。我有一个配对单词的单元格数组,我使用 psychtoolbox 来显示单词。我不断收到错误消息。
我使用大括号,并尝试引用单词的位置,但除非我对想要出现的单词进行硬编码,否则它永远不会出现单词,这不起作用,因为我希望单词以随机顺序出现以进行实验。
%这是我的阵列设置:
Word1 = {'shaky'; 'salty'; 'dizzy'; 'ideal'; 'jogging'; 'sweater';
'brainstorming'; 'weightlifting'};
Word2 = {'easel'; 'shaky'; 'lofty'; 'dizzy'; 'whistle'; 'jogging';
'weightlifting'; 'sportsmanship'};
DotSpot = { 'top'; 'top'; 'bottom'; 'bottom'; 'top'; 'top'; 'bottom';
'bottom'};
Target = { 'fall'; 'fall';
'fall';'fall';'active';'active';'active';'active'};
Category = { 'congruent';'incongruent'; 'incongruent';
'congruent';'congruent';'incongruent'; 'incongruent'; 'congruent'};
StimList = table(Word1, Word2, DotSpot, Target, Category);
%这是我的屏幕设置:
CompScreen = get(0,'ScreenSize'); % Find out the size of this computer
screen
win = Screen('OpenWindow',0, CompScreen); %[900 900 1000],
white=WhiteIndex(win);
Screen('FillRect', win, white);
Screen('TextSize',win, 30);
Screen('TextFont',win, 'Courier New');
Screen('TextStyle', win, 1);
%这里是我现在尝试只显示一个单词的地方,但一切都出错了:
Screen('DrawText', win, StimList{1,1} , 500, 500, [0, 0, 0]);
Screen(win, 'Flip');
WaitSecs(.5);
KbWait;
斯卡;
解决方案
Screen 'DrawText' 函数需要一个字符串,但是在您的示例中,您为其提供了一个包含字符串的元胞数组。将一级索引进一步放入元胞数组将返回 DrawText 所期望的字符串:
Screen('DrawText', win, StimList{1,1}{:} , 500, 500, [0, 0, 0]);
推荐阅读
- ffmpeg - 如何在启用 libsrt 的情况下编译 ffmpeg
- java - Scala 拆分代码
- entity-framework - 如何扩展 LinqKit 并在 linq 查询中使用自定义方法?
- c# - C# - PBDKF2,空值
- angular - mat-autoComplete 中的占位符不起作用,如 Angular Material Documentation 中所示
- angular - 带有项目列表的模式
- c# - 如何在应用程序退出之前重复执行一个方法而不影响 GUI?C# WPF
- angularjs - Angularjs:显示旧值的变量范围
- android - 房间错误:查询返回的列没有字段fieldname
- c# - 从 Internet 服务器连接数据库