Home > custom > grid_tools > slimagesc.m

slimagesc

PURPOSE ^

PURPOSE: slimagesc prints a 2D slice of a 3D array elements of a matrix M, reducing it along dimesion [d].

SYNOPSIS ^

function [h] = slimagesc(M,dim)

DESCRIPTION ^

 PURPOSE: slimagesc prints a 2D slice of a 3D array elements of a matrix M, reducing it along dimesion [d]. 
          E.g. slimagesc([1x100x100],1) plots a 100x100 image. 
          This is just for saving the reshape needed for imagesc().   
 ------------------------------------------------------------------------
 USAGE: [h] = slimagesc(M,dim,Sa,Sb)
 where: [M] is the slice of the 3D array to plot and
        [dim] is the dimension to reduce
-------------------------------------------------------------------------
 OUTPUTS:
        [h] SLIMAGESC returns a handle to a figure.
 ------------------------------------------------------------------------

 Notes: Function was written for quick and easy imaging of DEMs from an
       array stack without needing to use reshape evertime to reduce arrays to
       2D.

 Uses: imagesc()
 See also: imagesc

 Felix Hebeler, Geography Dept., University Zurich, October 2006.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [h] = slimagesc(M,dim)
0002 % PURPOSE: slimagesc prints a 2D slice of a 3D array elements of a matrix M, reducing it along dimesion [d].
0003 %          E.g. slimagesc([1x100x100],1) plots a 100x100 image.
0004 %          This is just for saving the reshape needed for imagesc().
0005 % ------------------------------------------------------------------------
0006 % USAGE: [h] = slimagesc(M,dim,Sa,Sb)
0007 % where: [M] is the slice of the 3D array to plot and
0008 %        [dim] is the dimension to reduce
0009 %-------------------------------------------------------------------------
0010 % OUTPUTS:
0011 %        [h] SLIMAGESC returns a handle to a figure.
0012 % ------------------------------------------------------------------------
0013 %
0014 % Notes: Function was written for quick and easy imaging of DEMs from an
0015 %       array stack without needing to use reshape evertime to reduce arrays to
0016 %       2D.
0017 %
0018 % Uses: imagesc()
0019 % See also: imagesc
0020 %
0021 % Felix Hebeler, Geography Dept., University Zurich, October 2006.
0022 
0023 % some checking
0024 if nargin ~= 2
0025     error('You need exactly 2 input arguments for this function');
0026 end
0027 
0028 n=[1:size(size(M),2)];
0029 n(n==dim)=[];
0030 
0031 imagesc(reshape(M,size(M,n(1)),size(M,n(2))))

Generated on Tue 24-Feb-2009 19:14:50 by m2html © 2003