Arrays have incompatible sizes for this operation problem in if statement
Show older comments
I'm coding a project for my first year uni course and when proposing an if statement i keep getting the same error and my code is so simple i cant find anything that answers my question online. when running this code i keep getting the error: Arrays have incompatible sizes for this operation.
Can anyone see what the problem is? When i remove the elseif, and just have the one 'if' statement the program runs and gives the correct data.

% use inp variable to determine what dataset to load
playerstats = readtable('stats.csv');
players = playerstats{1:64,'Player'};
[indx,tf] = listdlg('ListString',players,'Name','What player would you like to see stats for?');
% what stat does the user want to see
statview = input('What stat would you like to see from this player? (kd, kills, kills per life, damage per life, team kills, game points)','s');
%convert to matrix
ps = table2cell(playerstats);
psm = cell2mat(ps(:,4:10));
% determining stat option
if statview == 'kd'
disp(psm(indx,1))
elseif statview == 'kills'
disp(psm(indx,2))
end
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!