%Mfile for Chapter 11: Troubleshooting
delete chap11.txt
diary chap11.txt
echo on
clear all

plot = gcf;
x = -2:0.1:2;
%Typing plot(x, x.^2) indeed gives the indicated error message
which plot
clear plot
plot(x, x.^2)
pause

5^2/3 - 25/2*3
5^(2/3) -25/(2*3)
pause

X = -1:0.1:1;
%Typing X[1] gives the indicated error message
% and typing A = (0,1,2) also gives the indicated error message
sin 3
char(51)
pause

{'a', 'b'}
['a', 'b']
pause

% Typing 2 - *4 gives the indicated error message

%The two misspelled "fzero" lines give the indicated error messages
text = help('fzero'); text(1:38)
fzero(inline('x^2-3'), 1)
pause

% The mesh command with the square root of negative values gives 
% the error message indicated; but 
[X, Y] = meshgrid(-1:0.1:1, -1:0.1:1);
mesh(X, Y, sqrt(max(1 - X.^2 -Y.^2, 0)))
pause
print -deps trouble2.eps

syms p t
ezsurf(sin(p)*cos(t), sin(p)*sin(t), cos(p), [0, pi, 0, 2*pi]); axis equal
pause
close all

clear p t
ezsurf('sin(p)*cos(t)', 'sin(p)*sin(t)', 'cos(p)', ...
[0, pi, 0, 2*pi]); axis equal
pause

%This file accesses three versions of "shadecurves", the incorrect
%first version in Chapter 11, the second partially corrected version,
%and the third fully corrected version.

close all
shadecurves1('sin(x)', '-sin(x)', 0, pi)
pause
print -deps trouble3.eps

hold off
syms x; shadecurves1(x^2, sqrt(x), 0, 1)
pause
print -deps trouble5.eps

close all
syms x; shadecurves2(x^2, sqrt(x), 0, 1)
pause
print -deps trouble6.eps

close all
shadecurves2(x^2, x^4, -1.5, 1.5)
pause
print -deps trouble7.eps

close all
shadecurves3(x^2, x^4, -1.5, 1.5)
pause
print -deps trouble9.eps

close all
shadecurves3(sin(x), -sin(x), 0, pi)
pause
print -deps trouble4.eps


echo off
diary off
