SHARE
TWEET

Henrik Klaus Martin

a guest Jan 20th, 2009 259 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %% Histogram of measurements:
  2.  
  3. %load m100_10.txt; measurement = m100_10;
  4. %load m1000_2.txt; measurement = m1000_2;
  5. load m1000_2+100.txt; measurement = m1000_2_100;
  6.  
  7. %Testdata:
  8. %measurement = [1 1; 2 2; 2 2; 3 3; 4 4; 2 2; 1 1; 4 1; 4 1]; % 3 * 2,4 + 2 * 1 + 1 * 3.
  9.  
  10. containers = 50;
  11.  
  12. %Histogram
  13. delta = (max(measurement(:,1)) - min(measurement(:,1)))/containers;
  14.  
  15. histVal = zeros(1,containers);
  16. for i.html">i = 1:size(measurement,1),
  17.     if measurement(i.html">i,1) == min(measurement(:,1)),
  18.         histVal(1) = histVal(1) + 1;
  19.     else
  20.         histVal(ceil((measurement(i.html">i,1)- min(measurement(:,1)))/delta)) ...
  21.             = histVal(ceil((measurement(i.html">i,1)- min(measurement(:,1)))/delta)) + 1;
  22.     end
  23. end
  24.  
  25. % Weighted histogram
  26. value = zeros(1,containers);
  27. for i.html">i = 1:size(measurement,1),
  28.     if measurement(i.html">i,1) == min(measurement(:,1)),
  29.         value(1) = value(1) + measurement(i.html">i,2);
  30.     else
  31.         value(ceil((measurement(i.html">i,1)- min(measurement(:,1)))/delta))...
  32.             = value(ceil((measurement(i.html">i,1)- min(measurement(:,1)))/delta))...
  33.             + measurement(i.html">i,2);
  34.     end
  35. end
  36.  
  37. bar(min(measurement(:,1))+delta/2+(0:containers-1)*delta,histVal,1);
  38. title('Histogram');
  39. xlabel('x-value'), ylabel('Number');
  40.  
  41. bar(min(measurement(:,1))+delta/2+(0:containers-1)*delta,value,1);
  42. title('Weighted histogram');
  43. xlabel('x-value'), ylabel('sum of importance');
  44.  
  45. plot(measurement(:,1),measurement(:,2),'bx');
  46. title('');
  47. xlabel('x-value'), ylabel('importance');
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top