首页 > 解决方案 > 如何将单元格数组中的字符读取到 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;

斯卡;

标签: arraysmatlabpsychtoolbox

解决方案


Screen 'DrawText' 函数需要一个字符串,但是在您的示例中,您为其提供了一个包含字符串的元胞数组。将一级索引进一步放入元胞数组将返回 DrawText 所期望的字符串:

Screen('DrawText', win, StimList{1,1}{:}  , 500, 500, [0, 0, 0]);

推荐阅读