MATLAB: Cannot run a word-stimulus perception experiment

experimentfunctionMATLABperceptionstimulus

Hi, below are three function scripts for my sample experiment. I've tried using a number stimulus which works perfectly, however I am getting no luck with four-letter word stimuli. When the word stimulus is supposedly to appear on the screen, only the first letter is shown. Then it is waiting for an input. I type the letter that was shown but there is no response. PLEASE HELP!! There's probably something wrong in my function scripts that I'm not seeing.
function[info_array] = collect_info()
prompt={'Number:','Name:','Age:'};
dlg_title = 'Participant info';
num_lines = 1;
%default value for number; we usually do not have a default name
defAns = {'1','',''};
info_array = inputdlg(prompt,dlg_title,num_lines,defAns);
function [accuracy_est] = word_perception(time_var)
%%%clear command window
clc
%%%design and save stimuli
V = ['farm'; 'door'; 'book'; 'tree'];
stimulus_file = 'stimulus_list.txt';
dlmwrite(stimulus_file,V);
%%%preallocate memory for subject responses
W=NaN(4,1);
%%%collect and save subject info
[info_array] = collect_info;
info_subject_file = 'subject_info.mat';
save(info_subject_file,'info_array')
%%%run experiment
for i = 1:size(V,1)
%%%display stimulus for specified interval time_var (in seconds)
stim = V(i,1);
disp(stim)
pause(1)
clc
%%%collect response
[user_output] = req_wordinput;
W(i,1) = user_output;
end
clc
%%%store response
response_file = 'response_list.txt';
dlmwrite(response_file,W);
%%%compute accuracy
accuracy_est = mean(V==W);
function[output_word] = req_wordinput()
valid_input = 0;
while~valid_input
display_message = ':';
output_word = input(display_message);
if ischar(output_word) & isequal(size(output_word),[1 1])
valid_input = 1;
else display ('Invalid input. Please try again!')
pause(1)
end
end

Best Answer

stim = V(i,:);
To be more flexible you can use cells to store words of different length:
V = {'me' 'you' 'others'};
stim = V{i};