spreads subplots on several figures according to a maximum number of subplots per figure INPUTS i: subplot number imax: total number of subplots irow: maximum number of rows in a figure icol: maximum number of columns in a figure fig_title: title to be repeated on each figure
0001 function my_subplot(i,imax,irow,icol,fig_title) 0002 % spreads subplots on several figures according to a maximum number of 0003 % subplots per figure 0004 % 0005 % INPUTS 0006 % i: subplot number 0007 % imax: total number of subplots 0008 % irow: maximum number of rows in a figure 0009 % icol: maximum number of columns in a figure 0010 % fig_title: title to be repeated on each figure 0011 nfig_max = irow*icol; 0012 if imax < nfig_max 0013 icol = ceil(sqrt(imax)); 0014 irow=icol; 0015 if (icol-1)*(icol-2) >= imax 0016 irow = icol-2; 0017 icol = icol-1; 0018 elseif (icol)*(icol-2) >= imax 0019 irow = icol-2; 0020 elseif icol*(icol-1) >= imax 0021 irow = icol-1; 0022 end 0023 end 0024 0025 i1 = mod(i-1,nfig_max); 0026 if i1 == 0 0027 figure('Name',fig_title); 0028 end 0029 0030 subplot(irow,icol,i1+1);