Advertisement
Guest User

weeeeeed

a guest
Mar 29th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.61 KB | None | 0 0
  1. function []=plotdigit(A)
  2. % Translate vector to become nonnegative
  3. % Scale to interval [0,20]
  4. % Reshape the vector as a matrix and then show image
  5.  
  6. a1=squeeze(A);  
  7. a1=reshape(a1,16,16)';  
  8. minval=-1; maxval=1;
  9. % Rescale
  10. a1=-a1;
  11. a1=(a1-minval*ones(size(a1)));
  12. len=200;
  13. a1=(len/maxval)*a1/2;
  14. max(max(a1))
  15. min(min(a1))
  16. mymap1=(linspace(0,1,len))'*[1,1,1];
  17. %mymap1 =[1.0000    1.0000    1.0000
  18. %    0.8715    0.9028    0.9028
  19. %    0.7431    0.8056    0.8056
  20. %    0.6146    0.7083    0.7083
  21. %    0.4861    0.6111    0.6111
  22. %    0.3889    0.4722    0.5139
  23. %    0.2917    0.3333    0.4167
  24. %    0.1944    0.1944    0.3194
  25. %    0.0972    0.0972    0.1806
  26. %         0         0    0.0417];
  27. colormap(mymap1);
  28.  
  29.  
  30. image(a1)
  31.  
  32. x = C\testdata;
  33. b = C*x;
  34. subplot(2,2,1), plotdigit(b(:,26)), title('kolumn 2');
  35. subplot(2,2,2), plotdigit(testdata(:,26), title('kolumn 3'));
  36. %i våran matris C så vill vi ta första kolumnen för att testa dne mot
  37. %plotdigit för att se hur den ser ut.
  38. %{
  39. tva = C(:,2);
  40.  
  41. tre = C(:,3);
  42.  
  43. fem = C(:,5);
  44.  
  45. fyra = C(:,4);
  46.  
  47. sex = C(:,10);
  48.  
  49. sju = C(:,15);
  50.  
  51. atta = C(:,25);
  52.  
  53. nio = C(:,35);
  54.  
  55. tio = C(:,45);
  56.  
  57.  
  58.  
  59. subplot(3,3,1), plotdigit(tva), title('kolumn 2')
  60. subplot(3,3,2), plotdigit(tre), title('kolumn 3')
  61. subplot(3,3,3), plotdigit(fyra), title('kolumn 4')
  62. subplot(3,3,4), plotdigit(fem), title('kolumn 5')
  63. subplot(3,3,5), plotdigit(sex), title('kolumn 10')
  64. subplot(3,3,6), plotdigit(sju), title('kolumn 15')
  65. subplot(3,3,7), plotdigit(atta), title('kolumn 25')
  66. subplot(3,3,8), plotdigit(nio), title('kolumn 35')
  67. subplot(3,3,9), plotdigit(tio),, title('kolumn 45')
  68. %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement