我想用MATLAB
来设计一个非常简单的Stroop任务,参与者必须决定在屏幕上打印单词的颜色。出于某种原因,无论字体的大小如何,单词总是会被裁剪。如何防止文字在数字上出现裁剪?
我用下面的代码来设置数字尺寸:
h = figure('Position', [1, 1, 1200, 800]);
set(h, 'NumberTitle', 'off', ...
'Name', 'Stroop Test', ...
'Color', 'black', ...
'MenuBar','none', ...
'ToolBar', 'none');
对于显示实际字刺激,我用下面的代码:
ht = show_text(h, lang.words(iNoise),...
'FontSize', 60,...
'ForegroundColor', lang.colors{iStimul});
ADDED:
function handle = show_text(parrent, string, varargin)
parpos = get(parrent, 'Position');
pos = [5 round(parpos(4)/2)-30 parpos(3)-10 60];
handle = uicontrol(parrent,...
'Style','Text',...
'BackgroundColor', 'black',...
'ForegroundColor', 'white',...
'Position', pos,...
'FontUnits', 'pixels');
if length(varargin) > 0, set(handle, varargin{:}), end;
fontsize = get(handle, 'FontSize');
[outstring,newpos] = textwrap(handle,string);
height = length(outstring) * 1.1 * fontsize;
pos = [5 round(parpos(4)/2)-round(height/2) parpos(3)-10 height];
set(handle,'String',outstring,'Position', pos);
drawnow;
end
如果有人能告诉我问题是什么,那会很好。
你介意给我们展示'show_text'函数里有什么,它是一个自定义函数吗? – 2014-09-22 13:54:32
哎呀,忘了包括!只需添加它 – Alex 2014-09-22 13:55:15
如果需要,我可以包含实际脚本的链接 – Alex 2014-09-22 14:00:55