# HG changeset patch # User jwe # Date 1179331916 0 # Node ID 1b8daf8c03978394db36dd2be1050ec848eaf82a # Parent 0fcc8d65b571c2d8b396ed2f1ec5fa201c1f68cd [project @ 2007-05-16 16:11:55 by jwe] diff -r 0fcc8d65b571 -r 1b8daf8c0397 scripts/ChangeLog --- a/scripts/ChangeLog Wed May 16 15:32:09 2007 +0000 +++ b/scripts/ChangeLog Wed May 16 16:11:56 2007 +0000 @@ -1,3 +1,7 @@ +2007-05-16 Søren Hauberg + + * general/sub2ind.m, general/ind2sub.m: Doc fix. + 2007-05-16 John W. Eaton * general/logspace.m: Return second arg if fewer than two values diff -r 0fcc8d65b571 -r 1b8daf8c0397 scripts/general/ind2sub.m --- a/scripts/general/ind2sub.m Wed May 16 15:32:09 2007 +0000 +++ b/scripts/general/ind2sub.m Wed May 16 16:11:56 2007 +0000 @@ -20,6 +20,15 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{s1}, @var{s2}, @dots{}, @var{sN}] =} ind2sub (@var{dims}, @var{ind}) ## Convert a linear index into subscripts. +## +## The following example shows how to convert the linear index @code{8} +## in a 3-by-3 matrix into a subscript. +## +## @example +## [r, c] = ind2sub ([3, 3], 8) +## @result{} r = 2 +## c = 3 +## @end example ## @seealso{sub2ind} ## @end deftypefn diff -r 0fcc8d65b571 -r 1b8daf8c0397 scripts/general/sub2ind.m --- a/scripts/general/sub2ind.m Wed May 16 15:32:09 2007 +0000 +++ b/scripts/general/sub2ind.m Wed May 16 16:11:56 2007 +0000 @@ -21,6 +21,14 @@ ## @deftypefn {Function File} {@var{ind} =} sub2ind (@var{dims}, @var{i}, @var{j}) ## @deftypefnx {Function File} {@var{ind} =} sub2ind (@var{dims}, @var{s1}, @var{s2}, @dots{}, @var{sN}) ## Convert subscripts into a linear index. +## +## The following example shows how to convert the two-dimensional +## index @code{(2,3)} of a 3-by-3 matrix to a linear index. +## +## @example +## linear_index = sub2ind ([3, 3], 2, 3) +## @result{} 8 +## @end example ## @seealso{ind2sub} ## @end deftypefn diff -r 0fcc8d65b571 -r 1b8daf8c0397 src/ChangeLog --- a/src/ChangeLog Wed May 16 15:32:09 2007 +0000 +++ b/src/ChangeLog Wed May 16 16:11:56 2007 +0000 @@ -1,3 +1,7 @@ +2007-05-16 Søren Hauberg + + * ov.cc (Fsubsref, Fsubsasgn): Doc fix. + 2007-05-16 John W. Eaton * load-path.h (load_path::sys_path): New static data member. diff -r 0fcc8d65b571 -r 1b8daf8c0397 src/ov.cc --- a/src/ov.cc Wed May 16 15:32:09 2007 +0000 +++ b/src/ov.cc Wed May 16 16:11:56 2007 +0000 @@ -1951,6 +1951,25 @@ are @samp{\"()\"}, @samp{\"@{@}\"}, and @samp{\".\"}.\n\ The @samp{subs} field may be either @samp{\":\"} or a cell array\n\ of index values.\n\ +\n\ +The following example shows how to extract the two first columns of\n\ +a matrix\n\ +\n\ +@example\n\ +val = magic(3)\n\ + @result{} val = [ 8 1 6\n\ + 3 5 7\n\ + 4 9 2 ]\n\ +idx.type = \"()\";\n\ +idx.subs = @{\":\", 1:2@};\n\ +subsref(val, idx)\n\ + @result{} [ 8 1 \n\ + 3 5 \n\ + 4 9 ]\n\ +@end example\n\ +\n\ +@noindent\n\ +Note that this is the same as writing @code{val(:,1:2)}.\n\ @seealso{subsasgn, substruct}\n\ @end deftypefn") { @@ -1983,6 +2002,21 @@ are @samp{\"()\"}, @samp{\"@{@}\"}, and @samp{\".\"}.\n\ The @samp{subs} field may be either @samp{\":\"} or a cell array\n\ of index values.\n\ +\n\ +The following example shows how to set the two first columns of a\n\ +3-by-3 matrix to zero.\n\ +\n\ +@example\n\ +val = magic(3);\n\ +idx.type = \"()\";\n\ +idx.subs = @{\":\", 1:2@};\n\ +subsasgn (val, idx, 0)\n\ + @result{} [ 0 0 6\n\ + 0 0 7\n\ + 0 0 2 ]\n\ +@end example\n\ +\n\ +Note that this is the same as writing @code{val(:,1:2) = 0}.\n\ @seealso{subsref, substruct}\n\ @end deftypefn") {