sorting is not sorting?!

5 次查看(过去 30 天)
azaandria
azaandria 2021-2-16
评论: azaandria 2021-2-16
Using command sortrows(x,n) and it is not working? Any help would be appreciated please! Trying to sort column 3 in ascending order. My sort command is 2nd line to the last.
Thank you!
disp(' Test Scores by Student ID#');
disp(' ');
disp(' ID# T1 T2 T3');
disp(exam_scores);
student_5=exam_scores(5,:);
test_1=exam_scores(:,2);
test_2=exam_scores(:,3);
test_3=exam_scores(:,4);
test_scores=[test_1,test_2,test_3];
disp(' ');
disp('Student 5');
disp(student_5);
disp(' ');
disp('Test #1');
disp(test_1);
disp(' ');
disp('Standard Deviation for each test:');
std=std(test_scores);
disp(std);
disp(' ');
disp('Variance for each test:');
variance=(var(test_scores));
disp(variance);
disp(' ');
sum=sum(test_scores,2);
round_sum=round(sum);
possible_points=300;
students_score=(round_sum./possible_points);
percentage=(students_score.*100);
student_id=exam_scores(:,1);
table=[student_id,sum,percentage];
y=round(table);
disp(' ID# Pts %');
sortrows(y,3);
disp(y);

采纳的回答

dpb
dpb 2021-2-16
sortrows(y,3);
is a no-op because you didn't save the result.
y=sortrows(y,3);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by