Guest User

Untitled

a guest
Jan 20th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.56 KB | None | 0 0
  1. function currMax = findBlock(A)
  2. [numRows, numCols] = size(A);
  3. currMax = 0;
  4.  
  5. for (i = 1 : numRows)
  6.     row = A(1,:);
  7.     %Get longest run of 1s
  8.     count = getMaxRun(row);
  9.     for j = i+1 : numRows
  10.         row = bitand(row, A(j,:));
  11.         nuCount = getMaxRun(row) * (j - i + 1);
  12.         if nuCount >= count
  13.             count = nuCount;
  14.         else
  15.             break;
  16.         end
  17.        
  18.     end
  19.     if count > currMax
  20.         currMax = count;
  21.     end
  22. end
  23.  
  24. end
  25.  
  26. function maxRun = getMaxRun(vec)
  27. maxRun = max(diff(find([0 vec 0]~=1))) - 1;
  28. end
Add Comment
Please, Sign In to add comment