\input mweb.tex

\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


\N1.  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

\Y\P\F\\{maptype} \\{int}
\par
\P\F\\{maptype} \\{int}
\par
\P\F\\{maptype} \\{int}
\par
\P\F\\{maptype} \\{int}
\par
\P\F\\{maptype} \\{int}
\par
\P\F\\{maptype} \\{int}
\par
\P\F\\{maptype} \\{int}
\par
\Y\P$\|{x}=[\1\O{0}\ \O{0}\ \O{2}\ \pi,\;$\39$\O{2}{*}\pi,\;$\39$\O{5},\;$\39$%
\O{4.5}\ \O{20}\ \O{9243857}\ \infty]\2;\;$\6
$\|{a}=\O{1};\;$\6
$\|{b}=\O{2}$\6
$\|{c}=\pi/\O{4};\;$\6
$\\{bs\_ColourOpt}=\O{1}$\Y\par
\fi

\N2. 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: \CD{}\PB{$\&{if}\ $ $($ $\|{a}$ $=$ $\O{2}$ $)$}\DC{}, \CD{}\PB{$%
\&{elseif}\ $}\DC{}, \CD{}\PB{$\&{else}$}\DC{} and \CD{}\PB{$\&{end}$}\DC{}.

inserted \string\1 here: \1

\Y\P$\&{if}\ (\1\|{a}\I\|{b})\2$\1\6
$\|{a}=\|{b};\;$\2\6
$\&{end};\;$\7
$\&{if}\ (\1\|{a}\I\|{b})\2$\1\6
\X12:adjust baseline\X\relax\2\6
$\&{end};\;$\7
$\&{if}\ (\1\|{a}\S\|{b})\2$\1\6
$\|{a}=\\{some\_lousy\_variable\_with\_an\_ExtraordinaryLongName}$\6
$\\{text}(\1\O{2},\;$\39$\O{3},\;$\39$\.{'blah\ bla\ blah'})\2;\;$\2\6
$\&{elseif}\ $\1$(\1\|{a}<\|{b})\2$\6
$\\{text}(\1\O{5},\;$\39$\O{3},\;$\39$\.{'blah\ bla\ bla'})\2$\2\6
$\&{elseif}\ $\1$\|{x}$\6
$\&{if}\ \|{x}\S\O{1}$\1\6
$\|{y}=\|{x};\;$\2\6
$\&{elseif}\ $\1$(\1\|{x}\S\O{2})\2$\6
$\|{y}=\|{x}+\O{1};\;$\2\6
$\&{else}$\1\6
$\|{y}=\|{x}+\O{3};\;$\2\6
$\&{end};\;$\2\6
$\&{else}$\1\6
$\\{text}(\1\O{2},\;$\39$\O{3},\;$\39$\.{'blah\ bla\ blah'})\2;\;$\6
$\\{text}(\1\O{10},\;$\39$\O{7},\;$\39$\.{'bla\ blah\ blah'})\2;\;$\2\6
$\&{end};\;$\Y\par
\fi

\M3. An \CD{}\PB{$\&{if}\ $}\DC{} without braces:
\Y\P$\&{if}\ \|{a}\I\|{b}$\1\6
$\|{a}=\|{b};\;$\2\6
$\&{end};\;$\6
\X4:a \PB{$\&{for}\ $} loop\X\relax\6
$\|{c}=\O{2}/\O{3};\;$\Y\par
\fi

\N4. 2 for. Another example.
\Y\P\4\X4:a \PB{$\&{for}\ $} loop\X${}\S{}$\7
$\&{for}\ \|{i}=\O{1}\mathbin:\O{10}$\5
\C{ with a comment }\1\6
$\&{for}\ \|{j}=\O{1}\mathbin:\O{20}$\1\6
$\\{vect}(\1\|{i})\2=\\{matrix}(\1\O{2}{*}\|{i}+\O{1},\;$\39$\|{j})\2;\;$\2\6
$\&{end};\;$\2\6
$\&{end};\;$\Y\par
\A5.
\U3.\fi

\M5. vervolg.
\Y\P\4\X4:a \PB{$\&{for}\ $} loop\X${}\mathrel+\S{}$\7
$\&{for}\ \|{i}=[\1\O{1}\mathbin:\O{10}]\2$\1\6
$\\{vect}(\1\|{i})\2=\O{2}{*}\|{i}+\O{1};\;$\2\6
$\&{end};\;$\Y\par
\fi

\N6.  bs\_map.
Het volgende is overgenomen uit {\tt bs\_map.m}

\fi

\M7. For declarations like \CD{}\PB{$\&{clear}$}\DC{}, \CD{}\PB{$\&{global}$}%
\DC{} etc.:
\Y\P$\&{global}$\1\ $\\{PosInterval}\ \\{NegInterval}\ \\{bso\_Fine}\ \ldots$\6
$\\{bso\_Points}\ \\{bs\_BeginSampleNr}\ \\{bs\_EndSampleNr}\ \ldots$\6
$\\{bso\_MapAxSize}\ \\{bso\_Type}\ \\{bso\_Shoulders}\ \ldots$\6
$\\{bso\_PlusMinSize}\ \\{bso\_Grey}\ \\{bso\_Nlevels}$ $\ldots$\6
\X8:parameter handling\X\6
\X12:adjust baseline\X\6
\X13:make a figure window and axes\X\6
\X14:patient information\X\6
\X15:Make the map\X\6
\X18:print map info\X\6
\X19:create menu's\X\Y\par
\fi

\M8.  String handling:
\Y\P\4\X8:parameter handling\X${}\S{}$\6
$\\{bso\_ml}(\1\.{'Display'},\;$\39$\.{'no'})\2;\;$\6
$\\{bso\_map}(\1\.{'Display'},\;$\39$\.{'no'})\2;\;$\Y\par
\A9.
\U7.\fi

\M9.
\Y\P\4\X8:parameter handling\X${}\mathrel+\S{}$\6
$\&{if}\ (\1\\{bs\_ColourOpt}\W(\1\\{bso\_Type}\S\.{'p'}\V\\{bso\_Type}\S%
\.{'c'})\2)\2$\1\6
$\\{textcolour}=\.{'y'};\;$\2\6
$\&{else}$\1\6
$\\{textcolour}=\.{'k'};\;$\2\6
$\&{end};\;$\Y\par
\fi

\M10. In Matlab, the quote also serves as a transpose-operator:
\Y\P$\|{a}=\\{ones}(\1\O{3},\;$\39$\O{3})\2;\;$\6
$\|{c}=\|{b}^{\prime}$\6
$\|{c}=\O{4}^{\prime};\;$\6
$\|{c}=(\1\|{a}+\|{b})\2^{\prime};\;$\6
$\|{c}$ $=$ $(\1\|{a}+\O{4}i)\2$ $.$ $^{\prime}$ \Y\par
\fi

\M11. Quotes in a string.
\Y\P$\\{text}(\1\O{1},\;$\39$\O{2},\;$\39$\.{'He\ said:\ ''foo!'';\ ''''\ '})%
\2$\Y\par
\fi

\N12. 2 function calls.

\Y\P\4\D$\Nchannels\S$\5
$\O{64}$ \par
\P\F\\{Nchannels} \\{TeX}
\par
\Y\P\4\X12:adjust baseline\X${}\S{}$\6
$\\{bs\_Reg}=\\{ones}(\1\Nchannels,\;$\39$\O{500})\2;\;$\6
$\\{bs\_rejected}=\\{zeros}(\1\Nchannels)\2;\;$\6
$\\{bs\_BaseLineAlgorithm}=\O{1};\;$\6
$\\{bs\_BaseLn1}=\O{200};\;$\6
$\\{bs\_BaseLn2}=\O{400};\;$\6
$\\{bs\_BaseLineWidth}=\O{10};\;$\7
$\\{bs\_BA\_Reg}=\\{bs\_adj}(\1\ldots$\6
$\\{bs\_Reg},\;$\39$\\{bs\_rejected},\;$\39$\\{bs\_BaseLineAlgorithm},\;$\39$%
\ldots$\6
$\\{bs\_BaseLn1},\;$\39$\\{bs\_BaseLn2},\;$\39$\\{bs\_BaseLineWidth})\2;\;$\Y%
\par
\Us2\ET7.\fi

\M13.
\Y\P\4\X13:make a figure window and axes\X${}\S{}$\7
$\\{bs\_map\_winH}=\\{a4paper}(\1\\{bs\_FigScale})\2;\;$\6
$\\{bs\_map\_AX1}=\\{axes}(\1\ldots$\6
$\.{'Units'},\;$\39$\.{'normalized'},\;$\39$\ldots$\6
$\.{'Position'},\;$\39$[\1\O{0}\ \O{0}\ \O{1}\ \O{1}]\2,\;$\39$\ldots$\6
$\.{'Visible'},\;$\39$\.{'off'},\;$\39$\ldots$\6
$\.{'XLim'},\;$\39$[\1\O{0},\;$\39$\O{21}]\2,\;$\39$\ldots$\6
$\.{'YLim'},\;$\39$[\1\O{0}\ \O{29.7}]\2,\;$\39$\ldots$\6
$\.{'Clipping'},\;$\39$\.{'off'})\2;\;$\Y\par
\U7.\fi

\M14.
\Y\P\4\X14:patient information\X${}\S{}$\6
$\&{if}\ (\1\\{length}(\1\\{bs\_infostring})\2\G\O{16})\2$\1\6
$\\{text}(\1\O{3},\;$\39$\O{28.5},\;$\39$\\{bs\_infostring}(\1\O{10}\mathbin:%
\O{16})\2,\;$\39$\.{'Color'},\;$\39$\\{textcolour})\2;\;$\2\6
$\&{else}$\1\6
$\\{text}(\1\O{3},\;$\39$\O{28.5},\;$\39$\.{'?'},\;$\39$\.{'Color'},\;$\39$%
\\{textcolour})\2;\;$\2\6
$\&{end};\;$\6
$\\{text}(\1\O{7},\;$\39$\O{28.5},\;$\39$\\{bs\_filename},\;$\39$\.{'Color'},%
\;$\39$\\{textcolour})\2;\;$\Y\par
\U7.\fi

\M15.
\Y\P\4\X15:Make the map\X${}\S{}$\7
$\\{vec}=\\{zeros}(\1\O{64},\;$\39$\O{1})\2;\;$\6
$\\{vec}=\\{bs\_BA\_Reg}(\1\O{1}\mathbin:\O{64},\;$\39$\\{bs\_CurSampleNr})\2;%
\;$\6
$\\{bs\_Map}=\\{getmap}(\1\\{vec},\;$\39$\\{bs\_rejected})\2;\;$\6
\X16:define axes\X\6
\X17:call \PB{$\\{bsm}$}\X\Y\par
\U7.\fi

\M16.
\Y\P\4\X16:define axes\X${}\S{}$\6
$\\{bs\_map\_AX2}=\\{axes}(\1\ldots$\6
$\.{'Units'},\;$\39$\.{'normalized'},\;$\39$\ldots$\6
$\.{'Position'},\;$\39$[\1\O{4}/\O{21},\;$\39$\O{12}/\O{29.7},\;$\39$\\{bso%
\_MapAxSize}/\O{21},\;$\39$\\{bso\_MapAxSize}/\O{29.7}]\2,\;$\39$\ldots$\6
$\.{'Clipping'},\;$\39$\.{'off'})\2;\;$\Y\par
\Us15, 17\ETs18.\fi

\M17. Genest inspringen:
\Y\P\4\X17:call \PB{$\\{bsm}$}\X${}\S{}$\7
\X16:define axes\X\6
$\\{bsm}(\1\\{bs\_Map},\;$\39$\ldots$\6
$\.{'Type'},\;$\39$\\{bso\_Type},\;$\39$\ldots$\6
$\.{'Shoulders'},\;$\39$\\{bso\_Shoulders},\;$\39$\ldots$\6
$\.{'PlusMinSize'},\;$\39$\\{bso\_PlusMinSize},\;$\39$\ldots$\6
$\.{'Grey'},\;$\39$\\{bso\_Grey},\;$\39$\ldots$\6
$\.{'Fine'},\;$\39$\\{bso\_Fine},\;$\39$\ldots$\6
$\.{'Nlevels'},\;$\39$\\{bso\_Nlevels},\;$\39$\ldots$\6
$\.{'Leadnr'},\;$\39$\\{bso\_Leadnr},\;$\39$\ldots$\6
$\.{'Lead'},\;$\39$(\1\\{bs\_BA\_Reg}(\1\\{abs}(\1\\{bso\_Leadnr})\2,\;$\39$%
\\{bso\_Lead\_Begin}\mathbin:\\{bso\_Lead\_End})\2)\2,\;$\39$\ldots$\6
$\.{'Points'},\;$\39$[\1\\{bso\_Points}(\1\O{1})\2-\\{bso\_Lead\_Begin},\;$\39$%
\ldots$\6
$\\{bso\_Points}(\1\O{2})\2-\\{bso\_Lead\_Begin}]\2)\2;\;$\7
$\\{drawnow}$\5
\C{ Deze drawnow zorgt ervoor dat als er in het voorgaande een }\6
\C{ sequence lost raakt het script daar niet op blijft hangen. }\Y\par
\U15.\fi

\M18.
\Y\P\4\X18:print map info\X${}\S{}$\7
\X16:define axes\X\6
$\\{text}(\1\O{3},\;$\39$\O{6},\;$\39$[\1\.{'pos.\ contour\ interval:\ '},\;$%
\39$\\{num2str}(\1\\{PosInterval})\2]\2,\;$\39$\ldots$\6
$\.{'Color'},\;$\39$\\{textcolour})\2;\;$\6
$\\{text}(\1\O{3},\;$\39$\O{5},\;$\39$[\1\.{'neg.\ contour\ interval:\ '},\;$%
\39$\\{num2str}(\1\\{NegInterval})\2]\2,\;$\39$\ldots$\6
$\.{'Color'},\;$\39$\\{textcolour})\2;\;$\6
$\\{text}(\1\O{3},\;$\39$\O{4},\;$\39$[\1\.{'Sample:\ '},\;$\39$\\{num2str}(\1%
\\{bs\_CurSampleNr})\2]\2,\;$\39$\ldots$\6
$\.{'Color'},\;$\39$\\{textcolour})\2;\;$\6
$\\{text}(\1\O{3},\;$\39$\O{3},\;$\39$[\1\.{'Baseline:\ '},\;$\39$\ldots$\6
$\\{num2str}(\1\\{bs\_BaseLn1})\2,\;$\39$\.{'\ \ \ \ '},\;$\39$\ldots$\6
$\\{num2str}(\1\\{bs\_BaseLn2})\2]\2,\;$\39$\.{'Color'},\;$\39$\\{textcolour})%
\2;\;$\Y\par
\U7.\fi

\M19. De extra ruimte wordt gegenereerd door dubbele newlines, die in MWEB
equivalent zijn met \verb"@#".
\Y\P\4\X19:create menu's\X${}\S{}$\7
$\\{bs\_bsmWin\_PrintMenu}=\\{uimenu}(\1\.{'Label'},\;$\39$\.{'Print'},\;$\39$%
\.{'Separator'},\;$\39$\.{'on'})\2;\;$\7
$\\{bs\_bsmWin\_PrintSubMenu}=\\{uimenu}(\1\\{bs\_bsmWin\_PrintMenu},\;$\39$%
\ldots$\6
$\.{'Label'},\;$\39$\.{'\ '},\;$\39$\ldots$\6
$\.{'Separator'},\;$\39$\.{'on'},\;$\39$\ldots$\6
$\.{'Callback'},\;$\39$[\1\.{'print\ -dps\ -f'},\;$\39$\\{num2str}(\1\\{gcf})%
\2]\2)\2;\;$\Y\par
\U7.\fi

\M20. functiedefinities:

\Y\P$\&{function}\ $\1$\\{blah}(\1\\{arg1},\;\\{arg2})\2$\7
$\|{a}$ $=$ $\&{function}\ $\1$\\{boeh}(\1\\{arg1})\2$\7
$\&{for}\ \|{i}=\O{1}\mathbin:\O{3}$\1\6
$\|{a}=\|{b}+\|{c}(\1\|{i})\2$\2 $\&{end}$\6
$\\{bs\_map\_AX2}=\\{axes}(\1\ldots$\6
$\.{'Units'},\;$\39$\.{'normalized'},\;$\39$\ldots$\6
$\.{'Position'},\;$\39$[\1\O{4}/\O{21},\;$\39$\O{12}/\O{29.7},\;$\39$\\{bso%
\_MapAxSize}/\O{21},\;$\39$\\{bso\_MapAxSize}/\O{29.7}]\2,\;$\39$\ldots$\6
$\.{'Clipping'},\;$\39$\.{'off'})\2;\;$\par
\fi


\inx
\:\\{abs}, 17.
\:\\{arg1}, 20.
\:\\{arg2}, 20.
\:\\{axes}, 13, 16, 20.
\:\\{a4paper}, 13.
\:\\{blah}, 20.
\:\\{boeh}, 20.
\:\\{bs\_adj}, 12.
\:\\{bs\_BA\_Reg}, 12, 15, 17.
\:\\{bs\_BaseLineAlgorithm}, 12.
\:\\{bs\_BaseLineWidth}, 12.
\:\\{bs\_BaseLn1}, 12, 18.
\:\\{bs\_BaseLn2}, 12, 18.
\:\\{bs\_BeginSampleNr}, \[7].
\:\\{bs\_bsmWin\_PrintMenu}, 19.
\:\\{bs\_bsmWin\_PrintSubMenu}, 19.
\:\\{bs\_ColourOpt}, 1, 9.
\:\\{bs\_CurSampleNr}, 15, 18.
\:\\{bs\_EndSampleNr}, \[7].
\:\\{bs\_FigScale}, 13.
\:\\{bs\_filename}, 14.
\:\\{bs\_infostring}, 14.
\:\\{bs\_Map}, 15, 17.
\:\\{bs\_map\_AX1}, 13.
\:\\{bs\_map\_AX2}, 16, 20.
\:\\{bs\_map\_winH}, 13.
\:\\{bs\_Reg}, 12.
\:\\{bs\_rejected}, 12, 15.
\:\\{bsm}, 17.
\:\\{bso\_Fine}, \[7], 17.
\:\\{bso\_Grey}, \[7], 17.
\:\\{bso\_Lead\_Begin}, 17.
\:\\{bso\_Lead\_End}, 17.
\:\\{bso\_Leadnr}, 17.
\:\\{bso\_map}, 8.
\:\\{bso\_MapAxSize}, \[7], 16, 20.
\:\\{bso\_ml}, 8.
\:\\{bso\_Nlevels}, \[7], 17.
\:\\{bso\_PlusMinSize}, \[7], 17.
\:\\{bso\_Points}, \[7], 17.
\:\\{bso\_Shoulders}, \[7], 17.
\:\\{bso\_Type}, \[7], 9, 17.
\:\\{drawnow}, 17.
\:\\{gcf}, 19.
\:\\{getmap}, 15.
\:\\{int}, 1.
\:\\{length}, 14.
\:\\{maptype}, \[1].
\:\\{matrix}, 4.
\:$\Nchannels$, \[12].
\:\\{NegInterval}, \[7], 18.
\:\\{num2str}, 18, 19.
\:\\{ones}, 10, 12.
\:\\{PosInterval}, \[7], 18.
\:\\{some\_lousy\_variable\_with\_an\_ExtraordinaryLongName}, 2.
\:\\{TeX}, 12.
\:\\{text}, 2, 11, 14, 18.
\:\\{textcolour}, 9, 14, 18.
\:\\{uimenu}, 19.
\:\\{vec}, 15.
\:\\{vect}, 4, 5.
\:\\{zeros}, 12, 15.
\fin
\:\X15:Make the map\X
\U7.
\:\X4, 5:a \PB{$\&{for}\ $} loop\X
\U3.
\:\X12:adjust baseline\X
\Us2\ET7.
\:\X17:call \PB{$\\{bsm}$}\X
\U15.
\:\X19:create menu's\X
\U7.
\:\X16:define axes\X
\Us15, 17\ETs18.
\:\X13:make a figure window and axes\X
\U7.
\:\X8, 9:parameter handling\X
\U7.
\:\X14:patient information\X
\U7.
\:\X18:print map info\X
\U7.
\con

.
