SHARE
TWEET

Untitled

a guest Dec 9th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. % Ranking Project
  2.  %AML/B5/Dec-2019
  3.  %% Load extrnal data  files
  4. load -ascii Pure.txt
  5. load -ascii Applied.txt
  6. load -ascii Chemistry.txt
  7. load -ascii Physics.txt
  8. %% Define a matrix and store data in it
  9. all_data=zeros(30,6);
  10. all_data(:,1)=1:30;
  11. all_data(:,2)=Pure(:,2);
  12. all_data(:,3)=Applied(:,2);
  13. all_data(:,4)=Chemistry(:,2);
  14. all_data(:,5)=Physics(:,2);
  15. all_data(:,6)=all_data(:,2)+all_data(:,3)+all_data(:,4)+all_data(:,5);
  16. %% Part 1 Subject highest with Index No
  17. disp('Part:1')
  18. disp(['Max Pure ',num2str(max(all_data(:,2))),',and SID is: ',num2str(find(all_data(:,2)== max(all_data(:,2))))])
  19. disp(['Max Applied ',num2str(max(all_data(:,3))),',and SID is: ',num2str(find(all_data(:,3)== max(all_data(:,3))))])
  20. disp(['Max Chemistry ',num2str(max(all_data(:,4))),',and SID is: ',num2str(find(all_data(:,4)== max(all_data(:,4))))])
  21. disp(['Max Physics ',num2str(max(all_data(:,5))),',and SID is: ',num2str(find(all_data(:,5)== max(all_data(:,5))))])
  22. disp(' ')
  23. %% Part 2 Class Highest with student IDs
  24. all_data=sortrows(all_data,-6);
  25. disp('Part:2')
  26. disp(['1st rank SID: ',num2str(all_data(1,1)),', and the mark is: ',num2str(all_data(1,6))])
  27. disp(['2nd rank SID: ',num2str(all_data(2,1)),', and the mark is: ',num2str(all_data(2,6))])
  28. disp(['3rd rank SID: ',num2str(all_data(3,1)),', and the mark is: ',num2str(all_data(3,6))])
  29. disp(' ')
  30. %% Part 3 mean and STD for each subject
  31. disp('Part:3')
  32. disp(['Mean mk for Pure is: ', num2str(mean(all_data(:,2))), ' and STD is: ', num2str(std(all_data(:,2)))])
  33. disp(['Mean mk for Applied is: ', num2str(mean(all_data(:,3))), ' and STD is: ', num2str(std(all_data(:,3)))])
  34. disp(['Mean mk for Chemistry is: ', num2str(mean(all_data(:,4))), ' and STD is: ', num2str(std(all_data(:,4)))])
  35. disp(['Mean mk for Physics is: ', num2str(mean(all_data(:,5))), ' and STD is: ', num2str(std(all_data(:,5)))])
  36. disp(' ')
  37. %% Part 4 No. of failed students
  38. disp('Part:4')
  39. disp(' ')
  40. %% Part 5: re-writing the matrix
  41. all_datanew=[[1:30]',all_data(:,1),all_data(:,6),all_data(:,2:5)];
  42. %% To save this as a text file
  43. save -ascii RankingRM.txt all_datanew
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top