Matrix dimensions will not agree for 'if' statement

Hi, I am attempting to run the following code, whereby, depending on the key that a candidate presses during a trial, a certain number is chosen randomly using the data stored in the ‘resultsMatrix’ structure. This number is then used to define the prize money the candidate receives.

choosing_trial_prize_1 = randi(4);
choosing_trial_prize_2 = randi(4);    
if resultsMatrix(choosing_trial_prize_1).Key2 == 'LeftArrow' % the cell resultsMatrix(choosing_trial_prize_1).Key2 contains the output of KbName(keyCode1), where keyCode1 is the arrow pressed. 
    winning_distribution_1 = resultsMatrix(choosing_trial_prize_1).Sleftnumbers;
elseif resultsMatrix(choosing_trial_prize_1).Key2 == 'RightArrow'
    winning_distribution_1 = resultsMatrix(choosing_trial_prize_1).Srightnumbers;
end
  
if resultsMatrix(choosing_trial_prize_2).Key2 == 'LeftArrow'
    winning_distribution_2 = resultsMatrix(choosing_trial_prize_2).Sleftnumbers;
elseif resultsMatrix(choosing_trial_prize_2).Key2 == 'RightArrow'      
    winning_distribution_2 = resultsMatrix(choosing_trial_prize_2).Srightnumbers;
end

prize_1 = randi(str2num(winning_distribution_1));
prize_2 = randi(str2num(winning_distribution_2));
overall_prize = prize_1 + prize_2;

line10 = 'Congratulations, you have won:';
line11 = num2str(overall_prize);

However, I keep getting the following error:

Matrix dimensions must agree.

Error in Perceptual_trial_test 
if resultsMatrix(choosing_trial_prize_2).Key2 == 'LeftArrow'

How may I resolve this issue? Any suggestions would be much appreciated. Thanks in advance.

This sounds a matlab question, not a PTB one. You probably need to use “LeftArrow”, i.e., double quotation marks, or

if strcmp(resultsMatrix(choosing_trial_prize_2).Key2, 'LeftArrow')