forked from vasi786/ProjectAllocation-SourceCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSorting_CGPA.m
More file actions
71 lines (50 loc) · 1.55 KB
/
Sorting_CGPA.m
File metadata and controls
71 lines (50 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
clc;
%#################### Sorting CGPA and Roll no's accordingly##############
[num_sort,txt_sort] = xlsread('name_CGPA_2'); % importing the file
txt_headers = string(txt_sort(1,:)); % First row contains headings
button = 'NAME'
button_2 = 'CGPA'
button_3 = 'roll no'
for i = 1: length(txt_headers)
if strcmpi(txt_headers(i),button)
disp(['The candidate name column is : (', num2str(i),')'])
name_column = i;
elseif strcmpi(txt_headers(i),button_2)
disp(['The CGPA column is : (', num2str(i),')'])
CGPA_column = i;
elseif strcmpi(txt_headers(i),button_3)
disp(['The Roll no column is : (', num2str(i),')'])
Roll_no_column = i;
end
end
CGPA = num_sort(:,CGPA_column);
[sorted_CGPA,sort_index] = sort(CGPA,'descend');
%%%%%%%%%%%%%%%%%%%%%% adding seperate column to differentiate same CGPA %%
a = sorted_CGPA;
[ii,jj,kk]=unique(a);
repeated=ii(histc(kk,1:numel(ii))>1);
k = 1;
while true
for i = 1: length(a)
for j = i:length(a)
if repeated(k) == a(j)
a(j,2) = k;
end
end
end
k = k + 1;
if k > length(repeated)
break
end
end
clear k
clear repeated
clear i
clear j
sorted_CGPA = a;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Roll_nos_CGPA = num_sort(:,Roll_no_column);
sorted_Roll_nos = Roll_nos_CGPA(sort_index,:);
format longG
sorted_details = [sort_index sorted_Roll_nos sorted_CGPA];
%########################################################################