% setup.m Accepts data and organizes it. % Most "mother" programs start with the following: clear % removes all previously defined variables before = 0; after = 1; % assing numerical values to these strings type = before; % enter the data you want to analyze if type < after disp('before data'); % prints this to the main window beforedata; % reads beforedata.m flowmult = -1; % "before" flow readings are in the wrong direction (use later) else disp('after data'); % prints this to the main window afterdata; % reads afterdata.m flowmult = 1; %"after" flow readings are fine indexBic = 18; indexBS = 26; end [nimages nvalues] = size(DATA); %size(matrix) returns [number of rows, number of columns] %nimages now is the number of time frames = 397 %nvalues is the number of data points at each frame = 52 %DATA is a 397 x 52 Matrix n = 120; % this assigns the number of time frames to investigate % Break up the data into Time,Ap,Vp,Af, % For some reason, the flow meter was calibrated for the opposite direction in the % before data. So we will multiply flow by negative one if data is before and by one % if the data is after. % Furthermore, Af lags actual flow across the valve so we step ahead 3 time frames. % I estimated this 3 from the animpfplots results. It may not be the best choice. for i=1:n Time(i) = DATA(i,1); Ap(i) = DATA(i,50); Vp(i) = DATA(i,51); Af(i) = flowmult * DATA(i+3,52); end % Break up the (X,Y,Z) data into x,y,z matrices. % i will count the rows (time frame index) % j will be the crystal number (data element index) % subtracting the apex crystal locations guarantees that all % plots will have an apex at (0,0,0). for i=1:n ooo = [DATA(i,47) DATA(i,48) DATA(i,49)]; %the apex will always be (0,0,0) for j=1:16 x(i,j) = DATA(i,2+3*(j-1))-ooo(1); y(i,j) = DATA(i,3+3*(j-1))-ooo(2); z(i,j) = DATA(i,4+3*(j-1))-ooo(3); end end % Now call the plotting file of your choice by uncommenting one of the following % crystalplot %plots the 11 crystals % pressflowplots %plots pressures and flows for the number of time frames indicated by n % animpfplots % this will help find index numbers of important points in the cycle deltaVplot