Advertisement
EstebanRojas

exercise06

Jun 6th, 2024
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.88 KB | None | 0 0
  1. %----------------------------------------------------------------------------
  2. %  INTELIGENCIA ARTIFICIAL - 2024 - TP01
  3. %----------------------------------------------------------------------------
  4. % 6. Script 2. Dada la siguiente matriz booleana, diseñar un script que:
  5. %   a) Dada la matriz booleana simbolizada en la figura adjunta, diseñar
  6. %   un script que genere 15 matrices booleanas, del miso tamño, conteniendo
  7. %   cada una 15 “unos” dispuesto en forma aleatoria.
  8. %       a1) Comparar las 15 matrices con la matriz de muestra e identifcar
  9. %       las matrices de mayor y menor similitud.
  10. %       a2) Por cada comparacion realizada generar un indice de similitud    
  11. %       (IS pertenece a R) entre 0 y 1 (un valor IS=1 significa que las
  12. %        matrices son iguales). Orientacion: investigar el indice de Jaccard        
  13. % Comparar imagenes
  14. % https://la.mathworks.com/help/images/ref/imshowpair.html
  15. % Convertir imagen en matriz, viceversa
  16. % https://la.mathworks.com/help/images/ref/mat2gray.html#d126e91831
  17. % InitialMagnification
  18. % https://la.mathworks.com/help/images/ref/imshow.html?searchHighlight=imshow&s_tid=srchtitle_support_results_2_imshow#bvmnrxi-1-Reduce
  19. %----------------------------------------------------------------------------
  20. % Variables
  21. clc
  22. matrixAND=zeros(10,10);
  23. successN=0;
  24. booleanMatrix=zeros(10,10);
  25. IS=0;
  26. %----------------------------------------------------------------------------
  27. % Matriz Original
  28. booleanMatrixOriginal=zeros(10,10);
  29. booleanMatrixOriginal(2,7)=1;
  30. booleanMatrixOriginal(3,[5 6 8])=1;
  31. booleanMatrixOriginal(4,[4 9])=1;
  32. booleanMatrixOriginal([5 6],[3 10])=1;
  33. booleanMatrixOriginal(7,[2 10])=1;
  34. booleanMatrixOriginal(8,3)=1;
  35. booleanMatrixOriginal(9,4)=1;
  36. booleanMatrixOriginal(10,5)=1;
  37. %----------------------------------------------------------------------------
  38. % Comparo
  39. for i=1:15
  40.     booleanMatrixOriginal
  41.     booleanMatrix=booleanMatrixRandom()
  42.     matrixAND=booleanMatrixOriginal & booleanMatrix    
  43.     successN=size((find(matrixAND)),1);  
  44.     switch successN
  45.         case {1,2,3}
  46.             disp('La similitud es baja')
  47.             disp('INDICE DE SIMILITUD: ')
  48.             IS=successN/15
  49.         case{4,5,6,7}
  50.             disp('La similitud sigue siendo baja')
  51.             disp('INDICE DE SIMILITUD: ')
  52.             IS=successN/15
  53.         case {8,9,10,11,12,13,14}
  54.             disp('Son casi identicas: ')
  55.             disp('INDICE DE SIMILITUD: ')
  56.             IS=sucessN/15
  57.         case 15
  58.             disp('FELICITACIONES!!!...')
  59.             disp('Son identicas')
  60.             disp('INDICE DE SIMILITUD: ')
  61.             IS=1
  62.         otherwise
  63.             disp('Ambas matrices son distintas')
  64.             disp('INDICE DE SIMILITUD: ')
  65.             IS
  66.     end
  67.     scriptGraphicOptional(booleanMatrixOriginal,booleanMatrix,matrixAND)
  68.     fprintf('----------------------------------- \n')
  69.     pause
  70.     close
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement