Advertisement
Francoo

Calculador de Somatório (simples)

Nov 7th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.24 KB | None | 0 0
  1. function [p np ntpc npc npi] = parcialcalc(mrk,key,np)
  2. %PARCIALCALC Calculates partial score of questions, UFSC-style.
  3. %   This function calculates the score reached on a certain
  4. %   question, UFSC-style. It uses the following method:
  5. %
  6. %   If NPC > NPI:
  7. %                NP - (NTPC - ( NPC - NPI  ) )
  8. %           P = ------------------------------
  9. %                            NP
  10. %   Else:   P = 0
  11. %
  12. %   Where:
  13. %   P: Final score
  14. %   NP: Number of prepositions (total)
  15. %   NTPC: Number of total correct prepositions
  16. %   NPC: Number of corrects prepositions marked
  17. %   NPI: Number of incorrects prepositions marked
  18. %
  19. %   It does some simple logic manipulations on the numbers
  20. %   after converted it into a binary array.
  21. %
  22. %   Usage:
  23. %  
  24. %   parcialcalc(sum,key,np)
  25. %  
  26. %   Where:  mrk: the value marked by the person
  27. %           key: the correct value
  28. %           np: number of prepositions within the question
  29. %
  30. %   It returns the following values respectively:
  31. %       [P, NP, NTPC, NPC, NPI]
  32.  
  33.  
  34. bit_sum=de2bi(mrk,np);
  35. bit_key=de2bi(key,np);
  36.  
  37. ntpc=sum(bit_key);
  38.  
  39. npc=sum(bitand(bit_sum,bit_key));
  40.  
  41. npi=sum(bitand(bit_sum,bitxor(bit_key,ones(1,np))));
  42.  
  43. if npc > npi
  44.     p=1-(ntpc-npc+npi)/np;
  45. else
  46.     p=0;
  47. end
  48.  
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement