home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / POLYFUN.DI$ / XYZCHK.M < prev   
Encoding:
Text File  |  1993-03-07  |  1.4 KB  |  52 lines

  1. function [msg,x,y,z,xi,yi] = xyzchk(x,y,z,xi,yi)
  2. %XYZCHK Check arguments to 3-D data routines.
  3. %
  4. %    [MSG,X,Y,Z] = XYZCHK(X,Y,Z)
  5. %      or
  6. %    [MSG,X,Y,Z,XI,YI] = XYZCHK(X,Y,Z,XI,YI)
  7.  
  8. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  9.  
  10. msg = [];
  11.  
  12.  
  13. [m,n] = size(z);
  14. if min(size(z))>1, % z is a matrix
  15.  
  16.   % Convert x,y to row and column matrices if necessary.
  17.   if min(size(x))==1 & min(size(y))==1,
  18.     [x,y] = meshgrid(x,y);
  19.     if size(x,2)~=n | size(y,1)~=m,
  20.       msg = 'The lengths of X and Y must match the size of Z.';
  21.       return
  22.     end
  23.   elseif min(size(x))==1 | min(size(y))==1,
  24.     msg = 'X and Y must both be vectors or both be matrices.';
  25.     return
  26.   else
  27.     if any(size(x)~=size(z)) | any(size(y)~=size(z)),
  28.       msg = 'Matrix X and Y must be the same size as Z.';
  29.       return
  30.     end
  31.   end
  32.  
  33. else % z is a vector
  34.   if min(size(x))~=1 | min(size(y))~=1,
  35.     msg = 'X and Y must be vectors when Z is.';
  36.     return
  37.   elseif length(x)~=length(z) | length(y)~=length(z),
  38.     msg = 'X and Y must be same length as Z.';
  39.     return
  40.   end
  41. end
  42.  
  43. if nargin>3, % Check interpolation arguments
  44.   % If x is a row and y is a column then build xi,yi matrices.
  45.   if size(xi,1)==1 & size(yi,2)==1,
  46.     [xi,yi] = meshgrid(xi,yi);
  47.   elseif any(size(xi)~= size(yi)), % Also create matrix if sizes differ
  48.     [xi,yi] = meshgrid(xi,yi);    
  49.   end
  50. end
  51.  
  52.