% this is deltaVplot.m % First we must decide when ejection begins. % You can get this from animpfplots and find the index where % ventricular pressure goes above aortic pressure. startindex = 27; %index where Vp goes above Ap. The beginning of ejection. endindex = 66; % index where Af = 0. The end of ejection. deltaVall(1) = 0; %The first value of all deltaV is assigned zero % Since Time is in Seconds and flow is in ml/min we need to change flow to ml/sec % or time to minutes. The latter is easier so we'll do that TimeMin = Time/60; for i = 2:n deltaVall(i) = deltaVall(i-1) + 1/2 * (Af(i) + Af(i-1)) * (TimeMin(i)-TimeMin(i-1)); end % The above gives us the change in volume througout the entire cycle ... hence "all" % We want it to cover only ejection oppdeltaV(1)=0 %The first value of the opposite of deltaV is zero. for i=2:endindex-startindex oppdeltaV(i) = deltaVall(startindex+i)-deltaVall(startindex); end deltaV = -1 * oppdeltaV % Now we have the ventricular change in volume during ejection. % We want to plot this with the correponding time. plot(Time(startindex:endindex-1),deltaV,'r.') title('Change in Ventricle volume during one ejection') xlabel('Time in Seconds') ylabel('deltaV in ml') %After running this the first time you should generate a plot where the ventricle loses %about 25 ml. This makes sense.