MATLAB: Could any one please advise me on what is wrong with this code

code problems

function classGrades = convertGrades NamesAndGrades (1:5,:)
L = 20; % size of M, NamesAndGrades
c = 11; % last column of the submatrix (of course c < L)
% create the submatrix (NamesAndGrades)
M = rand(L);
% extract the desired submatrix
grades = M(:,2:c);
end

Best Answer

Hi,
so, many problems :
first line : what is the name of your function ? convertGrades, NamesAndGrades ? and in this line (1:5,:) has nothing to do here.
last line : grades = M(:,2:c); the output of your function is classGrades which is not defined in your code, i guess you need classGrades = M(:,2:c); ?
so depends on what you want to do, but here is function which works :
function classGrades = convertGrades
L = 20;
c = 11;
M = rand(L);
classGrades = M(:,2:c);
end