SHARE
TWEET

Untitled

a guest Sep 22nd, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. load('Salina.mat');
  2.  
  3. for i = 0:16
  4.     % initialize matrices with length of 100000 to avoid reallocation
  5.     eval(sprintf('class%02d = zeros(100000,204);', i));
  6.     eval(sprintf('classIter%02d = 1;', i));
  7. end
  8. for row = 1:size(salinas_corrected, 1)
  9.     for col = 1:size(salinas_corrected, 2)
  10.         i = salinas_gt(row, col);
  11.         % load data into corresponding classes
  12.         eval(sprintf('class%02d(classIter%02d, :) = reshape(salinas_corrected(row, col, :), [1, size(salinas_corrected, 3)]);', i, i));
  13.         eval(sprintf('classIter%02d = classIter%02d + 1;', i, i));
  14.     end
  15. end
  16. for i = 0:16
  17.     % cut off excessive chunk
  18.     eval(sprintf('class%02d = class%02d(1:classIter%02d-1,:);', i, i, i));
  19. end
  20.  
  21. population = [];
  22. for i = 16:-1:1
  23.     eval(sprintf('population = [class%02d;population];', i));
  24. end
  25.  
  26. % clear up workspace
  27. clear -regexp ^classIter\d{2}$ ^salinas_
  28. clear row col i;
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
 
Top