%
disp(' surface_scatter_plot.m   ver 1.0   September 9, 2008');
disp(' by Tom Irvine');
disp(' ');
disp(' Surface Plot for Three Columns of Data. ');
disp(' ');
%
clear THF;
clear tri;
clear h;
clear xp;
clear yp;
clear zp;
%
disp(' Select data input method ')
disp('  1=data preloaded in matlab ')  
disp('  2=external ASCII file ');
method=input('');                 
disp(' ')
if(method==1)
        THF = input(' Enter the matrix:  ');
        xp=double(THF(:,1));
        yp=double(THF(:,2));
        zp=double(THF(:,3));      
        n=max(size(xp)); 
end
if(method==2)
        [filename, pathname] = uigetfile('*.*');
        filename = fullfile(pathname, filename);
%      
        fid = fopen(filename,'r');
        THF = fscanf(fid,'%g %g %g',[3 inf]);
        THF=THF';  
        xp=double(THF(:,1));
        yp=double(THF(:,2));
        zp=double(THF(:,3));      
        n=max(size(xp));      
end 
%
figure(1);
plot3(xp,yp,zp,'.-') 
grid('on');
tri = delaunay(xp,yp); 
figure(2); 
plot(xp,yp,'.') 
[r,c] = size(tri); 
disp(r) 
figure(3);
h = trisurf(tri, xp, yp, zp); 