function [correctedFP]=FPbackgroundsubtract(rawFP) background = mean(rawFP(:,end-1,:),3); %Need to make this array the same size as the full array so we can subtract %arrays rather than using slow looping. backgroundarray = repmat(meanbackground,[1,size(rawFP,2),size(rawFP,3)]); correctedFP = rawFP - backgroundarray;