SHARE
TWEET

Working Droplet Code

a guest Sep 19th, 2019 117 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %HOW TO SET UP PREREQUISITE DATA:
  2.  
  3. %For the case of RA-013-2a 0.25g:
  4. %Import .csv file "RA-013-2a 0.25g 30Hz (1)" as a Numeric Matrix and rename
  5. %it to "RA0132a025g1".
  6. %Simarly, do the same for the other 2 .csv files.
  7.  
  8. %Import the .csv file with the Row Start and Row End columns and 4 more
  9. %adjacent empty columns.
  10.  
  11. widthDifference = zeros(15, 1);
  12. middleCell = zeros(15, 1);
  13. newRowStart = zeros(15, 1);
  14. newRowEnd = zeros(15, 1);
  15.  
  16. %Finding the middle cell of all the droplets
  17. for i = 1:15 %height of droplet matrix
  18.     differenceValueTemp = droplets15(i,2) - droplets15(i,1);
  19.     droplets15(i,3) = differenceValueTemp;
  20.     middleValueTemp = droplets15(i,1) + (differenceValueTemp/2);
  21.     droplets15(i,4) = middleValueTemp;
  22. end
  23.  
  24. largestDifference = max(droplets15(:,3));
  25.  
  26. %Assigns new start and end points for the droplets using the
  27. %largestDifference. This is so that each droplet dataset is the same width
  28. %so we can add datasets together to find the average.
  29. %This also makes sure that all droplets are aligned through their centre.
  30. for i = 1:15
  31.     middleValueTemp = droplets15(i,4);
  32.     newRowStartTemp = ceil(middleValueTemp - (largestDifference/2));
  33.     newRowEndTemp = newRowStartTemp + largestDifference;
  34.     droplets15(i,5) = newRowStartTemp;
  35.     droplets15(i,6) = newRowEndTemp;
  36. end
  37.  
  38. B = RA0132a0g1;
  39. A = RA0132a0g2;
  40. C = RA0132a0g3;
  41.  
  42. %Locate droplets
  43. %column 1: x position
  44. %column 2: y height
  45. drop1 = A((droplets15(1,5):droplets15(1,6)),(1:2));
  46. drop2 = A((droplets15(2,5):droplets15(2,6)),(1:2));
  47. drop3 = A((droplets15(3,5):droplets15(3,6)),(1:2));
  48. drop4 = A((droplets15(4,5):droplets15(4,6)),(1:2));
  49. drop5 = A((droplets15(5,5):droplets15(5,6)),(1:2));
  50. drop6 = B((droplets15(6,5):droplets15(6,6)),(1:2));
  51. drop7 = B((droplets15(7,5):droplets15(7,6)),(1:2));
  52. drop8 = B((droplets15(8,5):droplets15(8,6)),(1:2));
  53. drop9 = B((droplets15(9,5):droplets15(9,6)),(1:2));
  54. drop10 = B((droplets15(10,5):droplets15(10,6)),(1:2));
  55. drop11 = C((droplets15(11,5):droplets15(11,6)),(1:2));
  56. drop12 = C((droplets15(12,5):droplets15(12,6)),(1:2));
  57. drop13 = C((droplets15(13,5):droplets15(13,6)),(1:2));
  58. drop14 = C((droplets15(14,5):droplets15(14,6)),(1:2));
  59. drop15 = C((droplets15(15,5):droplets15(15,6)),(1:2));
  60.  
  61. %Add all the droplets to a single matrix to make operations easier
  62. largeDropletMatrix = [drop1, drop2, drop3, drop4, drop5, drop6, drop7, drop8, drop9, drop10, drop11, drop12, drop13, drop14, drop15];
  63.  
  64. %On either side of each droplet, make height zero so that adjacent droplet
  65. %data doesn't affect the average.
  66. for k = 1:2:30
  67.     dropletNumber = (k + 1)/2;
  68.     droplet = largeDropletMatrix(:,(k:(k+1)));
  69.     %left side of drop
  70.     for i = 1:(droplets15(dropletNumber,1) - droplets15(dropletNumber,5) - 1)
  71.         if droplets15(dropletNumber,1) ~= droplets15(dropletNumber,5)
  72.             largeDropletMatrix(i,(k+1)) = 0;
  73.         end
  74.     end
  75.     %right side of drop
  76.     for i = (size(droplet,1)-(droplets15(dropletNumber,6)-droplets15(dropletNumber,2))):size(droplet,1)
  77.         if droplets15(dropletNumber,6) ~= droplets15(dropletNumber,2)
  78.             largeDropletMatrix(i,(k+1)) = 0;
  79.         end
  80.     end
  81. end
  82.  
  83. %Finding average droplet height over x axis.
  84. %Add all the height values of each droplet together and divide by the
  85. %number of droplets.
  86. meanDroplet = zeros((size(largeDropletMatrix,1)),2);
  87. for k = 1:2:30
  88.     meanDroplet = meanDroplet + largeDropletMatrix(:,(k:(k+1)));
  89. end
  90. meanDroplet = meanDroplet/(size(largeDropletMatrix,2)/2);
  91. meanDroplet2 = meanDroplet;
  92.  
  93. i = largestDifference + 1;
  94. j = 0;
  95.  
  96. %Resets all x axis data of droplets to range from 0 to the width of the
  97. %largest droplet so that they can be overlapped.
  98. for r = 1:i
  99.     for q = 1:2:30
  100.         meanDroplet2(r,1) = j;
  101.         %Overlap all droplets
  102.         largeDropletMatrix(r,q) = j;
  103.     end
  104.     j = j + 0.00005;
  105. end
  106.  
  107. figure;
  108.  
  109. x = meanDroplet2(:,1);
  110. y = meanDroplet2(:,2);
  111. p = plot(x,y, 'r');
  112. title('RA-013-2a Glycerol: 0.25g');
  113. xlabel('Length [mm]')
  114. ylabel('Height [nm]')
  115. p.LineWidth = 3;
  116.  
  117. hold on
  118. y2 = largeDropletMatrix(:,2);
  119. plot(x,y2)
  120. y3 = largeDropletMatrix(:,4);
  121. plot(x,y3)
  122. y4 = largeDropletMatrix(:,6);
  123. plot(x,y4)
  124. y5 = largeDropletMatrix(:,8);
  125. plot(x,y5)
  126. y6 = largeDropletMatrix(:,10);
  127. plot(x,y6)
  128. y7 = largeDropletMatrix(:,12);
  129. plot(x,y7)
  130. y8 = largeDropletMatrix(:,14);
  131. plot(x,y8)
  132. y9 = largeDropletMatrix(:,16);
  133. plot(x,y9)
  134. y10 = largeDropletMatrix(:,18);
  135. plot(x,y10)
  136. y11 = largeDropletMatrix(:,20);
  137. plot(x,y11)
  138. y12 = largeDropletMatrix(:,22);
  139. plot(x,y12)
  140. y13 = largeDropletMatrix(:,24);
  141. plot(x,y13)
  142. y14 = largeDropletMatrix(:,26);
  143. plot(x,y14)
  144. y15 = largeDropletMatrix(:,28);
  145. plot(x,y15)
  146. y16 = largeDropletMatrix(:,30);
  147. plot(x,y16)
  148. hold off
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