There are too many mistakes in your own code, so I might as well rewrite it for you.
Let's stick to my jokes and share them with everyone.
[data, txt] = xlsread ('d: \ test.xlsx',' input');
N = size (data,1); Percentage of students
avg=mean(data(:,2:4)'); % data: student number, language, number, foreign language
Data = [data average];
data sort = round( 100 * data sort)/ 100; % Keep two decimal places
[DATA,ind]=sort(datasort(:,end),“descend”); Percentage ranked by average score
outdata=[datasort(ind,:)[ 1: 1:N]']; %[ 1: 1:N] is the ranking.
Xlswrite ('d: \ test.xlsx ',outdata,' output ',' B2 '); % output results
outtxt=txt(ind,);
Xlswrite('D:\Test.xlsx ',outtxt,' output ',' A2 '); % output name
Titlename={' name',' student number',' language',' mathematics',' English',' average',' ranking'};
Xlswrite ('d: \ test.xlsx', title name,' output',' a1'); % output field name
It's easier to understand.