Reputation: 4180
I am trying to use MATLAB
to design a very simple Stroop task where participants have to decide the color that a word is printed in on the screen. For some reason, the words are always cropped regardless of how big or small the font is.
I used the following code to set the figure size:
h = figure('Position', [1, 1, 1200, 800]);
set(h, 'NumberTitle', 'off', ...
'Name', 'Stroop Test', ...
'Color', 'black', ...
'MenuBar','none', ...
'ToolBar', 'none');
For displaying the actual word stimuli, I used the following code:
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
If someone could tell me what the problem is, that would be great.
Upvotes: 3
Views: 149
Reputation: 3574
What happens if you offset the height
variable in the show_text
function by a larger arbitrary factor like this:
height = length(outstring) * 1.5 * font size;
Instead of 1.1
? Or try 2
.
Upvotes: 1
Reputation: 7026
Not a direct answer to your question, but I'd strongly recommend PsychToolbox for this... There are many problems with using the matlab figure for experiments...
The problem you describe is just one of many, and that's why PsychToolbox, cogent etc. were written -- and they do make it easier to code this kind of task.
Upvotes: 1