clear
echo on
%errortrap on  <-- sadly removed in MATLAB 6

type isprime
pause

%Testing both versions of absval.m...
absval(-4)
absval(3)
absval2(-4)
absval2(3)
pause

%Testing signum.m...
signum(-4)
signum(0)
signum(3)
pause

%Testing commands in Logical Expressions section...
help relop
2 > 3
2 < 3
2 | 3
[2 3] < [3 2]
x = -2:2; x >= 0
x(x >= 0)
x(3:5)
pause

%Testing all 4 versions of sinxoverx.m...
sinxoverx(0)
sinxoverx(pi/2)
sinxoverx([0 pi/2])
sinxoverx2([0 pi/2; -pi/2 0])
sinxoverx3([0 pi/2; -pi/2 0])
sinxoverx4([0 pi/2; -pi/2 0])
pause

%Testing count.m...
count(1)
count(2)
count(3)
count(-1)
pause

help switch
help strcmp
type hold
pause

%Testing loops...

n = 1;
oldsum = -1;
newsum = 0;
while newsum > oldsum
    oldsum = newsum;
    newsum = newsum + n^(-4);
    n = n + 1;
    echo off
end
echo on
newsum

newsum = 0;
for n = 1:100000
    oldsum = newsum;
    newsum = newsum + n^(-4);
    if newsum == oldsum
        break
    end
    echo off
end
echo on
newsum
pause

%Testing subfunctions
sumcuberoots([-1 0 8])
type ezplot
pause

%Testing both versions of add.m...
add(-4, 3, 5)
add(-4, 3)
%add(-4, 3, 5, 7)  <-- produces an error message
add2(-4, 3, 5, 7)
pause

%Testing 3rd version of add.m...
add2(sym(-4), 3)
add2('asdf', 'qwerty')
%add3(sym(-4), 3)  <-- produces an error message
%add3('asdf', 'qwerty')  <-- produces an error message
add3(-4, 3)
pause

%Testing both versions of rectangular.m...
[x, y] = rectangular(2,1)
rectangular(2,1)
[x, y] = rectangular2(2,1)
rectangular2(2,1)
pause

%Testing input/output...
x = 2 + 2; disp(['The answer is ' num2str(x) '.'])
while 1
    answer = input(['Algorithm is converging slowly; ' ...
        'continue (yes/no)? '], 's');
    if ~isequal(answer, 'yes')
        break
    end
end
figure
xmarksthespot
pause

%Testing eval/feval...
eval('cos(1)')
feval('atan2', 1, 0)
feval(@atan2, 1, 0)
iterate('cos', 1, 2)
iterate('cos', 1, 100)

%Debugging commands
help dbstop

%Testing dos/unix...
[stat, data] = dos('echo 0.5 1000')

%I/O commands
help sscanf
help iofun
%errortrap off
echo off
