I tried using the following code for the output variables.My data (Fl_ERSP_mu) has total 9 blocks where I need 4 parameters for each block. I have shared the first two blocks for your reference. I am looking for a loop which can carry out this function for each block. Also, using this script I am unable to gerenate the average variables in the workspace. Kindly assist.
m=Fl_ERSP_mu(:,2) == 1.0720 %block1onset
n=Fl_ERSP_mu(:,2) == 1.8880 %block1offset
o= Fl_ERSP_mu(:,2) == 2.2880 %block2onset
p= Fl_ERSP_mu(:,2) == 3.6800 %block2offset
if Fl_ERSP_mu(:,2) == 1.0720
B1_preOn= range (Fl_ERSP_mu(m-20:m,:));
B1_preOn_avg= mean (B1_preOn,"all") %mean of B1_preonset
B1_postOn= range (Fl_ERSP_mu(m:m+20,:));
B1_postOn_avg= mean (B1_postOn,"all") %mean of B1_postonset
elseif Fl_ERSP_mu(:,2) == 1.8880
B1_preOff= range (Fl_ERSP_mu(n-20:n,:))
B1_preOff_avg= mean (B1_preOff,"all") %mean of B1_preoffset
B1_postOff= range (Fl_ERSP_mu(n:n+20,:));
B1_postoff_avg= mean (B1_postOff,"all") %mean of B1_postoffset
elseif Fl_ERSP_mu(:,2) == 2.2880
B2_preOn= range (Fl_ERSP_mu(o-20:o,:));
B2_preOn_avg= mean (B2_preOn,"all") %mean of B2_preonset
B2_postOn= range (Fl_ERSP_mu(o:o+20,:));
B2_postOn_avg= mean (B2_postOn,"all") %mean of B2_postonset
elseif Fl_ERSP_mu(:,2) == 3.6800
B2_preOff= range (Fl_ERSP_mu(p-20:p,:));
B2_preOff_avg= mean (B2_preOff,"all") %mean of B2_preoffset
B2_postOff= range (Fl_ERSP_mu(p:p+20,:));
B2_postoff_avg= mean (B2_postOff,"all") %mean of B2_postoffset
end