\def\title{Een testprogramma voor MWEB (Matlab Web)}
\def\xwebContentsTop{\bfseries
  \hrule\par\medskip
  \centerline{\Large\title}
  \vspace{2cm}
  \centerline{\large Mark Potse}
  \vspace{2cm}}  % this material will start the table of contents page
\def\Nchannels{N_{{\rm channels}}}
\par\medskip\hrule
@* Test. Deze file dient voor het testen van {\tt MWEB} (Matlab Web).
Het bevat geen zinvol programma, maar alleen veel verschillende
matlab-structuren voor het
testen van de parser van {\tt mweave}.
% test the rebinder
\gdef\1{This is the replacement text of \string\1}
 Mark Potse
 e-mail: potse@@amc.uva.nl
@f maptype int
@f maptype int
@f maptype int
@f maptype int
@f maptype int
@f maptype int
@f maptype int
@u
x = [0 0 2 pi, 2*pi, 5, 4.5 20 9243857 inf];
a = 1;
b = 2
c = pi/4;
bs_ColourOpt = 1
@*2 if-elseif-else-end constructions. In the title of a ``starred
section'' program text may not be used, but in the documentation it
may: |if (a=2)|, |elseif|, |else| and |end|.
inserted \string\1 here: \1
@u
if (a ~= b)
  a = b;
end; 
if (a ~= b)
  @< adjust baseline @> @;
end ;
if (a == b)
  a = some_lousy_variable_with_an_ExtraordinaryLongName
  text(2, 3, 'blah bla blah');
elseif ( a< b)
  text(5, 3, 'blah bla bla')
elseif x
  if x == 1
     y = x;
  elseif (x == 2)
     y = x + 1;
  else
     y = x + 3;
  end;
else
  text(2, 3, 'blah bla blah');
  text(10, 7, 'bla blah blah');
end;
@ An |if| without braces:
@u
if a ~= b
  a = b;
end;
@ @;
c = 2/3;
@*2 for. Another example.
@=
for i = 1:10	% with a comment
for j = 1:20
  vect(i) = matrix(2*i+1,j);
end;
end;
@ vervolg.
@=
for i = [1:10]
  vect(i) = 2*i+1;
end;
@* bs\_map.
Het volgende is overgenomen uit {\tt bs\_map.m}
@ For declarations like |clear|, |global| etc.:
@u
    global PosInterval     NegInterval      bso_Fine       ...
           bso_Points      bs_BeginSampleNr bs_EndSampleNr ...
           bso_MapAxSize   bso_Type         bso_Shoulders  ...
           bso_PlusMinSize bso_Grey         bso_Nlevels    ...
@< parameter handling @>
@< adjust baseline @>
@< make a figure window and axes @>
@< patient information @>
@< Make the map @>
@< print map info @>
@< create menu's @>
    
@  String handling:
@< parameter handling @>=
    bso_ml('Display','no');
    bso_map('Display','no');
@
@< parameter handling @>=
    if (bs_ColourOpt & (bso_Type=='p' | bso_Type=='c'))
       textcolour = 'y';
    else
       textcolour = 'k';
    end;
     
@ In Matlab, the quote also serves as a transpose-operator:
@u
a = ones(3,3);
c = b'   
c = 4'; c = (a+b)';  
c = (a + 4i).'   
@ Quotes in a string.
@u
text(1, 2, 'He said: ''foo!''; '''' ')
  
@*2 function calls.
@d Nchannels = 64
@f Nchannels TeX
@< adjust baseline @>=
bs_Reg = ones(Nchannels,500);
bs_rejected = zeros(Nchannels);
bs_BaseLineAlgorithm = 1;
bs_BaseLn1 = 200;
bs_BaseLn2 = 400;
bs_BaseLineWidth = 10;
    bs_BA_Reg = bs_adj( ...
       bs_Reg, bs_rejected, bs_BaseLineAlgorithm, ...
       bs_BaseLn1, bs_BaseLn2, bs_BaseLineWidth);
    
@ 
@< make a figure window and axes @>=
    bs_map_winH = a4paper(bs_FigScale);
    bs_map_AX1 = axes( ...
       'Units','normalized', ...
       'Position',[0 0 1 1], ...
       'Visible','off', ...
       'XLim',[0, 21], ...
       'YLim',[0 29.7], ...
       'Clipping','off');
@ 
@< patient information @>=
    if (length(bs_infostring) >= 16)
       text(3, 28.5, bs_infostring(10:16), 'Color', textcolour);
    else
       text(3, 28.5, '?', 'Color', textcolour);
    end;
    text(7, 28.5, bs_filename, 'Color', textcolour);
@ 
@< Make the map @>=
vec = zeros(64,1);
vec = bs_BA_Reg(1:64,bs_CurSampleNr);
bs_Map = getmap(vec,bs_rejected);
@< define axes @>
@< call |bsm| @> 
   
@ 
@< define axes @>=
      bs_map_AX2 = axes( ...
        'Units','normalized', ...
        'Position',[4/21, 12/29.7, bso_MapAxSize/21, bso_MapAxSize/29.7], ...
        'Clipping','off');
@ Genest inspringen:
@< call |bsm| @>=
    @< define axes @>
    bsm(bs_Map, ...
       'Type',bso_Type, ...
       'Shoulders',bso_Shoulders, ...
       'PlusMinSize',bso_PlusMinSize, ...
       'Grey',bso_Grey, ...
       'Fine',bso_Fine, ...
       'Nlevels',bso_Nlevels, ...
       'Leadnr',bso_Leadnr, ...
       'Lead',(bs_BA_Reg(abs(bso_Leadnr),bso_Lead_Begin:bso_Lead_End)), ...
       'Points',[bso_Points(1)-bso_Lead_Begin, ...
                 bso_Points(2)-bso_Lead_Begin]);
    drawnow  % Deze drawnow zorgt ervoor dat als er in het voorgaande een
             % sequence lost raakt het script daar niet op blijft hangen.
@ 
@< print map info @>=
    @< define axes @>
    text (3, 6,['pos. contour interval: ', num2str(PosInterval)], ...
      'Color', textcolour);
    text (3, 5,['neg. contour interval: ', num2str(NegInterval)], ...
      'Color', textcolour);
    text (3, 4,['Sample: ', num2str(bs_CurSampleNr)], ...
        'Color', textcolour);
    text (3, 3,['Baseline: ', ...
        num2str(bs_BaseLn1), '    ', ...
        num2str(bs_BaseLn2)], 'Color', textcolour);
@ De extra ruimte wordt gegenereerd door dubbele newlines, die in MWEB
equivalent zijn met \verb"@@#".
@< create menu's @>=
    bs_bsmWin_PrintMenu = uimenu('Label','Print','Separator','on');
   bs_bsmWin_PrintSubMenu = uimenu(bs_bsmWin_PrintMenu, ...
      'Label',' ', ...
      'Separator', 'on', ...
      'Callback',[ 'print -dps -f', num2str(gcf)]); 
@ functiedefinities:
@u  
function blah(arg1, arg2)
a = function boeh(arg1)
  
  for i = 1:3
     a = b + c(i)
  end
  bs_map_AX2 = axes( ...
        'Units','normalized', ...
        'Position',[4/21, 12/29.7, bso_MapAxSize/21, bso_MapAxSize/29.7], ...
        'Clipping','off');