Code covered by the BSD License  

Highlights from
smartSlice and iGSlice

image thumbnail

smartSlice and iGSlice

by

 

slice into irregular grids with smartSlice and iGSlice. NaN values are allowed.

hout=quickSlice(varargin)
function hout=quickSlice(varargin)
% quickSlice(X,Y,Z,V,Ix,Jy) Volumetric slice plot along grid
%    rows and columns.
%
% quickSlice(X,Y,Z,V,Ix,Jy) draws slices according to the indices given
%    in Ix and Jy. By allowing slices only over grid nodes, interpolation is
%    unncessary.
%    Ix gives the i index into X,Y,Z,V specifying the x value along which
%    to slice. Jy gives the j index specifying the y value along which to
%    slice. if Ix and Jy are vectors, a new slice will be created for each
%    value.
%  quickSlice(AX,...) plots into AX instead of GCA.
%
%   H = quickSlice(...) returns a vector of handles to SURFACE objects.
%
%   The axes CLim property is set to span the finite values of V.
%
%   SEE ALSO, iGSlice, slice, meshgrid, surface.

% James Ramm $Date: 23/01/2011 16:25:18 $
% james.ramm@geo.au.dk

[cax,args,nargs] = axescheck(varargin{:});
error(nargchk(4,6,nargs,'struct'));

cax = newplot(cax);
hold_state = ishold(cax);
nin = nargs;

if nin < 6
    error(id('WrongNumberOfInputs'),'Wrong number of input arguments.')
elseif nin == 6
    v = args{4};
    args{4} = [];
    if ndims(v)~=3, error(id('InvalidVDims'),'V must be a 3-D array.'); end
    [nx,ny,nz] = size(v);
    [x,y,z] = deal(args{1:3});
    [sx,sy] = deal(args{5:6});
end
h = [];
if sx

    
    for i = 1:length(sx)
        xx=(x(:,sx(i),:));
        yy=(y(:,sx(i),:));
        zz=(z(:,sx(i),:));
        vv=(v(:,sx(i),:));
size(xx)
        h = [h; surface(reshape(xx(:,1,:),[nx,nz]),reshape(yy(:,1,:),[nx,nz]),...
            reshape(zz(:,1,:),[nx,nz]),reshape(vv(:,1,:),[nx,nz]), ...
            'parent',cax)];
    end
end
if sy
    for i = 1:length(sy)
        xx=(x(sy(i),:,:));
        yy=(y(sy(i),:,:));
        zz=(z(sy(i),:,:));
        vv=(v(sy(i),:,:));
        h = [h; surface(reshape(xx(1,:,:),[ny,nz]),reshape(yy(1,:,:),[ny,nz]),...
            reshape(zz(1,:,:),[ny,nz]),reshape(vv(1,:,:),[ny,nz]), ...
            'parent',cax)];
    end
end
if nargout > 0
    hout = h;
end
if ~hold_state
    view(cax,3), grid(cax,'on')
end
% Use ISFINITE to make sure no NaNs or Infs get passed to CAXIS
u=v(isfinite(v)); u = u(:);
caxis(cax,[min(u) max(u)]);
% Signal to the world that we have created a new plot:
plotdoneevent(cax,h);

function str=id(str)
str = ['MATLAB:slice:' str];

Contact us