%
% tpt.m
%
% this routine gathers two points and
%   computes the slope of the connecting segment
%   and writes the 2 points to a data file called ptdat
%   this file is then piped to the c executable cslope
%   the output of which is piped to cout
%   finally cout is loaded back into matlab and displayed
%

disp('Please click on two points')
figure(1)
axis([-1 1 -1 1])
[x,y] = ginput(2);
hold on
plot(x,y);
m = diff(y)/diff(x);
disp(['  matlab slope = ' num2str(m)])
save ptdat x y -ascii

! cslope < ptdat > cout      

% the ! achieves "shell escape" while < and >
% pipe things in and out of cslope

load cout

disp(['  c slope = ' num2str(cout)])

