From bug-octave-request at bevo dot che dot wisc dot edu Tue Aug 1 11:00:53 2000 Subject: mesh*.m complex argument vectors From: Rolf Fabian To: "'bug-octave UWISC'" Date: Tue, 1 Aug 2000 11:01:36 -0500 (CDT) Hi, The help part of 'scripts/plot/meshgrid.m' says: ## The rows of at var{xx} are copies of @var{x}, ## and the columns of at var{yy} are copies of @var{y}. Depending on orientation, this is incorrect if complex x,y vectors are involved, namely if x is column type, or/and y is row type. Then erraneously complex conjugated copies are returned! e.g. :> [X,Y]=meshgrid([i;2i],[3i,4i]) X = 0 - 1i 0 - 2i 0 - 1i 0 - 2i Y = 0 - 3i 0 - 3i 0 - 4i 0 - 4i ( I've no idea what Matlab does in this case ) Note, that analogous incorrect features appears in all mesh*.m scripts, i.e. also in 'meshdom.m' and 'mesh.m'. Rolf Fabian simple correction for e.g. 'meshgrid.m' ( see lines *FIXED* ) ---- snip --- snip -- snip -- snip --- ## Copyright (C) 1996, 1997 John W. Eaton ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2, or (at your option) ## any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, write to the Free ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. ## -*- texinfo -*- ## at deftypefn {Function File} {[@var{xx}, @var{yy}] =} meshgrid (@var{x}, @var{y}) ## at deftypefnx {Function File} {[@var{xx}, @var{yy}] =} meshgrid (@var{x}) ## Given vectors of at var{x} and @var{y} coordinates, return two matrices corresponding ## to the at var{x} and @var{y} coordinates of a mesh. The rows of @var{xx} are copies of @var{x}, ## and the columns of at var{yy} are copies of @var{y}. ## at end deftypefn ## at seealso{sombrero, plot, semilogx, semilogy, loglog, polar, mesh, meshdom, contour, ## bar, stairs, gplot, gsplot, replot, xlabel, ylabel, and title} ## Author: jwe function [xx, yy] = meshgrid (x, y) if (nargin == 1) y = x; endif if (nargin > 0 && nargin < 3) if (is_vector (x) && is_vector (y)) xlen = length (x); ylen = length (y); xx = zeros (ylen, xlen); yy = zeros (ylen, xlen); if (columns (x) == 1) #x = x'; #original 2.1.31 x = x.'; #*FIXED* endif if (rows (y) == 1) #y = y'; #original 2.1.31 y = y.'; #*FIXED* endif for i = 1:ylen xx(i,:) = x; endfor for i = 1:xlen yy(:,i) = y; endfor else error ("meshgrid: arguments must be vectors"); endif else usage ("[xx, yy] = meshgrid (x, y)"); endif endfunction ---- snip --- snip -- snip -- snip -- ----------------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.che.wisc.edu/octave/octave.html How to fund new projects: http://www.che.wisc.edu/octave/funding.html Subscription information: http://www.che.wisc.edu/octave/archive.html -----------------------------------------------------------------------