annotate doc/interpreter/container.txi @ 19627:446c46af4b42 stable

strip trailing whitespace from most source files * Makefile.am, NEWS, build-aux/common.mk, configure.ac, doc/Makefile.am, doc/doxyhtml/Makefile.am, doc/interpreter/Makefile.am, doc/interpreter/arith.txi, doc/interpreter/audio.txi, doc/interpreter/basics.txi, doc/interpreter/bugs.txi, doc/interpreter/container.txi, doc/interpreter/cp-idx.txi, doc/interpreter/data.txi, doc/interpreter/debug.txi, doc/interpreter/diagperm.txi, doc/interpreter/diffeq.txi, doc/interpreter/doccheck/README, doc/interpreter/doccheck/spellcheck, doc/interpreter/emacs.txi, doc/interpreter/errors.txi, doc/interpreter/eval.txi, doc/interpreter/expr.txi, doc/interpreter/external.txi, doc/interpreter/fn-idx.txi, doc/interpreter/func.txi, doc/interpreter/geometry.txi, doc/interpreter/geometryimages.m, doc/interpreter/gpl.txi, doc/interpreter/grammar.txi, doc/interpreter/gui.txi, doc/interpreter/image.txi, doc/interpreter/install.txi, doc/interpreter/interp.txi, doc/interpreter/interpimages.m, doc/interpreter/intro.txi, doc/interpreter/io.txi, doc/interpreter/java.txi, doc/interpreter/linalg.txi, doc/interpreter/macros.texi, doc/interpreter/matrix.txi, doc/interpreter/munge-texi.pl, doc/interpreter/nonlin.txi, doc/interpreter/numbers.txi, doc/interpreter/obsolete.txi, doc/interpreter/octave-config.1, doc/interpreter/octave.texi, doc/interpreter/oop.txi, doc/interpreter/op-idx.txi, doc/interpreter/optim.txi, doc/interpreter/package.txi, doc/interpreter/plot.txi, doc/interpreter/poly.txi, doc/interpreter/preface.txi, doc/interpreter/quad.txi, doc/interpreter/set.txi, doc/interpreter/signal.txi, doc/interpreter/sparse.txi, doc/interpreter/sparseimages.m, doc/interpreter/splineimages.m, doc/interpreter/stats.txi, doc/interpreter/stmt.txi, doc/interpreter/strings.txi, doc/interpreter/system.txi, doc/interpreter/testfun.txi, doc/interpreter/tips.txi, doc/interpreter/var.txi, doc/interpreter/vectorize.txi, doc/liboctave/Makefile.am, doc/liboctave/array.texi, doc/liboctave/bugs.texi, doc/liboctave/cp-idx.texi, doc/liboctave/dae.texi, doc/liboctave/diffeq.texi, doc/liboctave/error.texi, doc/liboctave/factor.texi, doc/liboctave/fn-idx.texi, doc/liboctave/gpl.texi, doc/liboctave/install.texi, doc/liboctave/intro.texi, doc/liboctave/liboctave.texi, doc/liboctave/matvec.texi, doc/liboctave/nleqn.texi, doc/liboctave/nlfunc.texi, doc/liboctave/ode.texi, doc/liboctave/optim.texi, doc/liboctave/preface.texi, doc/liboctave/quad.texi, doc/liboctave/range.texi, doc/refcard/Makefile.am, doc/refcard/refcard.tex, etc/HACKING, etc/NEWS.1, etc/NEWS.2, etc/NEWS.3, etc/OLD-ChangeLogs/ChangeLog, etc/OLD-ChangeLogs/doc-ChangeLog, etc/OLD-ChangeLogs/scripts-ChangeLog, etc/OLD-ChangeLogs/src-ChangeLog, etc/OLD-ChangeLogs/test-ChangeLog, etc/PROJECTS, etc/README.Cygwin, etc/README.MacOS, etc/README.MinGW, etc/README.gnuplot, etc/gdbinit, etc/icons/Makefile.am, examples/@polynomial/end.m, examples/@polynomial/subsasgn.m, examples/Makefile.am, examples/standalonebuiltin.cc, libgui/Makefile.am, libgui/qterminal/libqterminal/README, libgui/qterminal/libqterminal/unix/BlockArray.cpp, libgui/qterminal/libqterminal/unix/BlockArray.h, libgui/qterminal/libqterminal/unix/Character.h, libgui/qterminal/libqterminal/unix/CharacterColor.h, libgui/qterminal/libqterminal/unix/Emulation.cpp, libgui/qterminal/libqterminal/unix/Emulation.h, libgui/qterminal/libqterminal/unix/Filter.cpp, libgui/qterminal/libqterminal/unix/Filter.h, libgui/qterminal/libqterminal/unix/History.cpp, libgui/qterminal/libqterminal/unix/History.h, libgui/qterminal/libqterminal/unix/KeyboardTranslator.cpp, libgui/qterminal/libqterminal/unix/KeyboardTranslator.h, libgui/qterminal/libqterminal/unix/LineFont.h, libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp, libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h, libgui/qterminal/libqterminal/unix/Screen.cpp, libgui/qterminal/libqterminal/unix/Screen.h, libgui/qterminal/libqterminal/unix/ScreenWindow.cpp, libgui/qterminal/libqterminal/unix/ScreenWindow.h, libgui/qterminal/libqterminal/unix/TerminalCharacterDecoder.cpp, libgui/qterminal/libqterminal/unix/TerminalCharacterDecoder.h, libgui/qterminal/libqterminal/unix/Vt102Emulation.h, libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp, libgui/qterminal/qterminal/main.cpp, libgui/src/m-editor/file-editor-tab.cc, libgui/src/octave-gui.cc, libgui/src/octave-qt-link.cc, libinterp/corefcn/data.cc, libinterp/corefcn/defun-int.h, libinterp/corefcn/det.cc, libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h, libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/lu.cc, libinterp/corefcn/oct-tex-parser.yy, libinterp/corefcn/oct-tex-symbols.in, libinterp/corefcn/quadcc.cc, libinterp/corefcn/zfstream.cc, libinterp/dldfcn/__eigs__.cc, libinterp/dldfcn/__voronoi__.cc, libinterp/gendoc.pl, libinterp/genprops.awk, libinterp/mk-errno-list, libinterp/mk-pkg-add, libinterp/mkbuiltins, libinterp/mkdefs, libinterp/mkdocs, libinterp/mkops, libinterp/octave-value/ov-java.cc, libinterp/parse-tree/lex.ll, libinterp/parse-tree/oct-parse.in.yy, libinterp/parse-tree/octave.gperf, liboctave/Makefile.am, liboctave/array/Array.cc, liboctave/array/module.mk, liboctave/cruft/daspk/datv.f, liboctave/cruft/daspk/dcnst0.f, liboctave/cruft/daspk/dcnstr.f, liboctave/cruft/daspk/ddasic.f, liboctave/cruft/daspk/ddasid.f, liboctave/cruft/daspk/ddasik.f, liboctave/cruft/daspk/ddaspk.f, liboctave/cruft/daspk/ddstp.f, liboctave/cruft/daspk/ddwnrm.f, liboctave/cruft/daspk/dfnrmd.f, liboctave/cruft/daspk/dfnrmk.f, liboctave/cruft/daspk/dhels.f, liboctave/cruft/daspk/dheqr.f, liboctave/cruft/daspk/dinvwt.f, liboctave/cruft/daspk/dlinsd.f, liboctave/cruft/daspk/dlinsk.f, liboctave/cruft/daspk/dmatd.f, liboctave/cruft/daspk/dnedd.f, liboctave/cruft/daspk/dnedk.f, liboctave/cruft/daspk/dnsd.f, liboctave/cruft/daspk/dnsid.f, liboctave/cruft/daspk/dnsik.f, liboctave/cruft/daspk/dnsk.f, liboctave/cruft/daspk/dorth.f, liboctave/cruft/daspk/dslvd.f, liboctave/cruft/daspk/dslvk.f, liboctave/cruft/daspk/dspigm.f, liboctave/cruft/daspk/dyypnw.f, liboctave/cruft/dasrt/ddasrt.f, liboctave/cruft/dasrt/drchek.f, liboctave/cruft/dassl/ddaslv.f, liboctave/cruft/dassl/ddassl.f, liboctave/cruft/misc/blaswrap.c, liboctave/cruft/misc/module.mk, liboctave/cruft/odepack/cfode.f, liboctave/cruft/odepack/dlsode.f, liboctave/cruft/odepack/ewset.f, liboctave/cruft/odepack/intdy.f, liboctave/cruft/odepack/prepj.f, liboctave/cruft/odepack/sintdy.f, liboctave/cruft/odepack/slsode.f, liboctave/cruft/odepack/solsy.f, liboctave/cruft/odepack/ssolsy.f, liboctave/cruft/odepack/stode.f, liboctave/cruft/odepack/vnorm.f, liboctave/cruft/ranlib/Basegen.doc, liboctave/cruft/ranlib/README, liboctave/cruft/ranlib/genbet.f, liboctave/cruft/ranlib/genexp.f, liboctave/cruft/ranlib/gennch.f, liboctave/cruft/ranlib/gennf.f, liboctave/cruft/ranlib/gennor.f, liboctave/cruft/ranlib/getsd.f, liboctave/cruft/ranlib/initgn.f, liboctave/cruft/ranlib/phrtsd.f, liboctave/cruft/ranlib/randlib.fdoc, liboctave/cruft/ranlib/setsd.f, liboctave/cruft/ranlib/tstgmn.for, liboctave/cruft/ranlib/tstmid.for, liboctave/cruft/slatec-fn/atanh.f, liboctave/cruft/slatec-fn/datanh.f, liboctave/cruft/slatec-fn/xgmainc.f, liboctave/cruft/slatec-fn/xsgmainc.f, liboctave/numeric/module.mk, liboctave/operators/mk-ops.awk, liboctave/operators/mx-ops, liboctave/operators/sparse-mk-ops.awk, liboctave/operators/sparse-mx-ops, liboctave/operators/vx-ops, liboctave/util/module.mk, run-octave.in, scripts/@ftp/ftp.m, scripts/audio/wavread.m, scripts/deprecated/java_convert_matrix.m, scripts/deprecated/java_debug.m, scripts/deprecated/java_invoke.m, scripts/deprecated/java_new.m, scripts/deprecated/java_unsigned_conversion.m, scripts/deprecated/javafields.m, scripts/deprecated/javamethods.m, scripts/deprecated/shell_cmd.m, scripts/general/accumarray.m, scripts/general/display.m, scripts/general/fieldnames.m, scripts/general/interp1.m, scripts/general/interp2.m, scripts/general/interp3.m, scripts/general/isa.m, scripts/general/methods.m, scripts/general/sortrows.m, scripts/geometry/convhull.m, scripts/geometry/delaunay.m, scripts/geometry/delaunay3.m, scripts/geometry/delaunayn.m, scripts/geometry/griddata.m, scripts/geometry/griddatan.m, scripts/geometry/voronoi.m, scripts/geometry/voronoin.m, scripts/gui/guihandles.m, scripts/gui/inputdlg.m, scripts/gui/listdlg.m, scripts/gui/msgbox.m, scripts/gui/questdlg.m, scripts/gui/uigetfile.m, scripts/gui/waitbar.m, scripts/gui/warndlg.m, scripts/help/doc.m, scripts/help/help.m, scripts/help/type.m, scripts/image/bone.m, scripts/image/cmpermute.m, scripts/image/cmunique.m, scripts/image/colorcube.m, scripts/image/colormap.m, scripts/image/contrast.m, scripts/image/gray2ind.m, scripts/image/image.m, scripts/image/imshow.m, scripts/image/ind2gray.m, scripts/image/jet.m, scripts/image/rgb2ntsc.m, scripts/image/spinmap.m, scripts/io/importdata.m, scripts/io/strread.m, scripts/io/textread.m, scripts/io/textscan.m, scripts/java/java_get.m, scripts/java/java_set.m, scripts/java/javaaddpath.m, scripts/java/javaclasspath.m, scripts/java/javamem.m, scripts/linear-algebra/linsolve.m, scripts/linear-algebra/qzhess.m, scripts/miscellaneous/debug.m, scripts/miscellaneous/desktop.m, scripts/miscellaneous/dir.m, scripts/miscellaneous/dos.m, scripts/miscellaneous/edit.m, scripts/miscellaneous/fact.m, scripts/miscellaneous/getappdata.m, scripts/miscellaneous/inputname.m, scripts/miscellaneous/license.m, scripts/miscellaneous/ls_command.m, scripts/miscellaneous/run.m, scripts/miscellaneous/setfield.m, scripts/miscellaneous/unix.m, scripts/miscellaneous/ver.m, scripts/mk-pkg-add, scripts/mkdoc.pl, scripts/optimization/fminsearch.m, scripts/optimization/optimset.m, scripts/optimization/sqp.m, scripts/pkg/pkg.m, scripts/pkg/private/create_pkgadddel.m, scripts/pkg/private/fix_depends.m, scripts/pkg/private/install.m, scripts/plot/appearance/axis.m, scripts/plot/appearance/box.m, scripts/plot/appearance/clabel.m, scripts/plot/appearance/daspect.m, scripts/plot/appearance/datetick.m, scripts/plot/appearance/grid.m, scripts/plot/appearance/legend.m, scripts/plot/appearance/orient.m, scripts/plot/appearance/shading.m, scripts/plot/appearance/text.m, scripts/plot/appearance/title.m, scripts/plot/appearance/xlabel.m, scripts/plot/appearance/ylabel.m, scripts/plot/appearance/zlabel.m, scripts/plot/draw/area.m, scripts/plot/draw/bar.m, scripts/plot/draw/barh.m, scripts/plot/draw/colorbar.m, scripts/plot/draw/contour.m, scripts/plot/draw/contour3.m, scripts/plot/draw/contourf.m, scripts/plot/draw/ellipsoid.m, scripts/plot/draw/errorbar.m, scripts/plot/draw/ezcontour.m, scripts/plot/draw/ezcontourf.m, scripts/plot/draw/ezmesh.m, scripts/plot/draw/ezpolar.m, scripts/plot/draw/fill.m, scripts/plot/draw/fplot.m, scripts/plot/draw/hist.m, scripts/plot/draw/meshc.m, scripts/plot/draw/meshz.m, scripts/plot/draw/pareto.m, scripts/plot/draw/patch.m, scripts/plot/draw/peaks.m, scripts/plot/draw/pie.m, scripts/plot/draw/pie3.m, scripts/plot/draw/plot.m, scripts/plot/draw/plotyy.m, scripts/plot/draw/private/__bar__.m, scripts/plot/draw/private/__contour__.m, scripts/plot/draw/private/__errplot__.m, scripts/plot/draw/private/__ezplot__.m, scripts/plot/draw/private/__patch__.m, scripts/plot/draw/private/__stem__.m, scripts/plot/draw/rectangle.m, scripts/plot/draw/ribbon.m, scripts/plot/draw/rose.m, scripts/plot/draw/scatter.m, scripts/plot/draw/scatter3.m, scripts/plot/draw/semilogx.m, scripts/plot/draw/shrinkfaces.m, scripts/plot/draw/sombrero.m, scripts/plot/draw/sphere.m, scripts/plot/draw/stairs.m, scripts/plot/draw/stem.m, scripts/plot/draw/stemleaf.m, scripts/plot/draw/surf.m, scripts/plot/draw/surface.m, scripts/plot/draw/surfc.m, scripts/plot/draw/surfl.m, scripts/plot/draw/surfnorm.m, scripts/plot/draw/tetramesh.m, scripts/plot/draw/trimesh.m, scripts/plot/draw/triplot.m, scripts/plot/draw/trisurf.m, scripts/plot/util/__gnuplot_drawnow__.m, scripts/plot/util/__plt_get_axis_arg__.m, scripts/plot/util/axes.m, scripts/plot/util/clf.m, scripts/plot/util/copyobj.m, scripts/plot/util/figure.m, scripts/plot/util/gcbo.m, scripts/plot/util/graphics_toolkit.m, scripts/plot/util/hggroup.m, scripts/plot/util/meshgrid.m, scripts/plot/util/newplot.m, scripts/plot/util/print.m, scripts/plot/util/private/__add_default_menu__.m, scripts/plot/util/private/__fltk_print__.m, scripts/plot/util/private/__gnuplot_print__.m, scripts/plot/util/private/__print_parse_opts__.m, scripts/plot/util/refreshdata.m, scripts/plot/util/subplot.m, scripts/polynomial/conv.m, scripts/polynomial/poly.m, scripts/polynomial/polyeig.m, scripts/polynomial/polyfit.m, scripts/polynomial/polyval.m, scripts/polynomial/private/__splinefit__.m, scripts/polynomial/spline.m, scripts/prefs/prefdir.m, scripts/prefs/preferences.m, scripts/prefs/private/prefsfile.m, scripts/prefs/rmpref.m, scripts/signal/freqz.m, scripts/signal/module.mk, scripts/sparse/eigs.m, scripts/sparse/pcg.m, scripts/sparse/private/__sprand_impl__.m, scripts/sparse/sprand.m, scripts/sparse/sprandn.m, scripts/sparse/spy.m, scripts/sparse/svds.m, scripts/specfun/expint.m, scripts/specfun/factor.m, scripts/special-matrix/gallery.m, scripts/special-matrix/hankel.m, scripts/special-matrix/toeplitz.m, scripts/startup/inputrc, scripts/statistics/base/kurtosis.m, scripts/statistics/base/moment.m, scripts/statistics/base/qqplot.m, scripts/statistics/base/var.m, scripts/statistics/distributions/betarnd.m, scripts/statistics/distributions/binoinv.m, scripts/statistics/distributions/binopdf.m, scripts/statistics/distributions/binornd.m, scripts/statistics/distributions/cauchy_rnd.m, scripts/statistics/distributions/chi2rnd.m, scripts/statistics/distributions/discrete_pdf.m, scripts/statistics/distributions/discrete_rnd.m, scripts/statistics/distributions/empirical_rnd.m, scripts/statistics/distributions/exprnd.m, scripts/statistics/distributions/frnd.m, scripts/statistics/distributions/gamrnd.m, scripts/statistics/distributions/geornd.m, scripts/statistics/distributions/hygernd.m, scripts/statistics/distributions/kolmogorov_smirnov_cdf.m, scripts/statistics/distributions/laplace_cdf.m, scripts/statistics/distributions/laplace_pdf.m, scripts/statistics/distributions/logistic_cdf.m, scripts/statistics/distributions/logistic_pdf.m, scripts/statistics/distributions/lognrnd.m, scripts/statistics/distributions/nbincdf.m, scripts/statistics/distributions/nbininv.m, scripts/statistics/distributions/nbinpdf.m, scripts/statistics/distributions/nbinrnd.m, scripts/statistics/distributions/normrnd.m, scripts/statistics/distributions/poissinv.m, scripts/statistics/distributions/poissrnd.m, scripts/statistics/distributions/tinv.m, scripts/statistics/distributions/trnd.m, scripts/statistics/distributions/unidcdf.m, scripts/statistics/distributions/unidpdf.m, scripts/statistics/distributions/unidrnd.m, scripts/statistics/distributions/unifrnd.m, scripts/statistics/distributions/wblrnd.m, scripts/statistics/models/module.mk, scripts/statistics/tests/kruskal_wallis_test.m, scripts/strings/base2dec.m, scripts/strings/deblank.m, scripts/strings/dec2base.m, scripts/strings/dec2bin.m, scripts/strings/dec2hex.m, scripts/strings/mat2str.m, scripts/strings/ostrsplit.m, scripts/strings/regexptranslate.m, scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strjoin.m, scripts/strings/strsplit.m, scripts/strings/strtok.m, scripts/strings/strtrim.m, scripts/strings/strtrunc.m, scripts/strings/substr.m, scripts/testfun/__run_test_suite__.m, scripts/testfun/speed.m, scripts/testfun/test.m, scripts/time/asctime.m, scripts/time/datenum.m, scripts/time/datevec.m, scripts/time/weekday.m, src/Makefile.am, test/Makefile.am, test/build-bc-overload-tests.sh, test/build-sparse-tests.sh, test/jit.tst, test/line-continue.tst: Strip trailing whitespace.
author John W. Eaton <jwe@octave.org>
date Tue, 20 Jan 2015 08:26:57 -0500
parents d63878346099
children 0e1f5a750d00
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17281
diff changeset
1 @c Copyright (C) 1996-2013 John W. Eaton
7018
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
2 @c
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
3 @c This file is part of Octave.
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
4 @c
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
5 @c Octave is free software; you can redistribute it and/or modify it
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
6 @c under the terms of the GNU General Public License as published by the
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
7 @c Free Software Foundation; either version 3 of the License, or (at
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
8 @c your option) any later version.
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
9 @c
7018
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
10 @c Octave is distributed in the hope that it will be useful, but WITHOUT
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
11 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
12 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
13 @c for more details.
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
14 @c
7018
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
15 @c You should have received a copy of the GNU General Public License
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
16 @c along with Octave; see the file COPYING. If not, see
fd42779a8428 [project @ 2007-10-13 00:52:12 by jwe]
jwe
parents: 7001
diff changeset
17 @c <http://www.gnu.org/licenses/>.
3439
3234a698073a [project @ 2000-01-14 09:51:14 by jwe]
jwe
parents:
diff changeset
18
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
19 @node Data Containers
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
20 @chapter Data Containers
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
21 @cindex containers
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
22
6939
46d1ad37d943 [project @ 2007-10-01 16:12:20 by jwe]
jwe
parents: 6868
diff changeset
23 Octave includes support for two different mechanisms to contain
9036
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
24 arbitrary data types in the same variable. Structures, which are C-like,
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
25 and are indexed with named fields, and cell arrays, where each element
9758
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
26 of the array can have a different data type and or shape. Multiple
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
27 input arguments and return values of functions are organized as
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
28 another data container, the comma separated list.
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
29
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
30 @menu
12596
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
31 * Structures::
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
32 * Cell Arrays::
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
33 * Comma Separated Lists::
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
34 @end menu
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
35
12596
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
36 @node Structures
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
37 @section Structures
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
38 @cindex structures
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
39 @cindex data structures
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
40
16816
12005245b645 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 16772
diff changeset
41 Octave includes support for organizing data in structures. The current
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
42 implementation uses an associative array with indices limited to
15615
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
43 strings, but the syntax is more like C-style structures.
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
44
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
45 @menu
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
46 * Basic Usage and Examples::
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
47 * Structure Arrays::
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
48 * Creating Structures::
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
49 * Manipulating Structures::
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
50 * Processing Data in Structures::
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
51 @end menu
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
52
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
53 @node Basic Usage and Examples
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
54 @subsection Basic Usage and Examples
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
55
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
56 Here are some examples of using data structures in Octave.
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
57
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
58 Elements of structures can be of any value type. For example, the three
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
59 expressions
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
60
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
61 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
62 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
63 x.a = 1;
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
64 x.b = [1, 2; 3, 4];
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
65 x.c = "string";
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
66 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
67 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
68
12175
2090995ca588 Correct en-dash,em-dash instances in docstrings.
Rik <octave@nomad.inbox5.com>
parents: 11537
diff changeset
69 @opindex .
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
70 @noindent
12175
2090995ca588 Correct en-dash,em-dash instances in docstrings.
Rik <octave@nomad.inbox5.com>
parents: 11537
diff changeset
71 create a structure with three elements. The @samp{.} character separates
2090995ca588 Correct en-dash,em-dash instances in docstrings.
Rik <octave@nomad.inbox5.com>
parents: 11537
diff changeset
72 the structure name from the field name and indicates to Octave that this
2090995ca588 Correct en-dash,em-dash instances in docstrings.
Rik <octave@nomad.inbox5.com>
parents: 11537
diff changeset
73 variable is a structure. To print the value of the
2090995ca588 Correct en-dash,em-dash instances in docstrings.
Rik <octave@nomad.inbox5.com>
parents: 11537
diff changeset
74 structure you can type its name, just as for any other variable:
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
75
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
76 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
77 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
78 x
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
79 @result{} x =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
80 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
81 a = 1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
82 b =
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
83
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
84 1 2
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
85 3 4
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
86
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
87 c = string
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
88 @}
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
89 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
90 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
91
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
92 @noindent
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
93 Note that Octave may print the elements in any order.
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
94
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
95 Structures may be copied just like any other variable:
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
96
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
97 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
98 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
99 y = x
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
100 @result{} y =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
101 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
102 a = 1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
103 b =
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
104
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
105 1 2
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
106 3 4
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
107
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
108 c = string
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
109 @}
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
110 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
111 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
112
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
113 Since structures are themselves values, structure elements may reference
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
114 other structures. The following statements change the value of the
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
115 element @code{b} of the structure @code{x} to be a data structure
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
116 containing the single element @code{d}, which has a value of 3.
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
117
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
118 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
119 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
120 x.b.d = 3;
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
121 x.b
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
122 @result{} ans =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
123 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
124 d = 3
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
125 @}
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
126
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
127 x
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
128 @result{} x =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
129 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
130 a = 1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
131 b =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
132 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
133 d = 3
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
134 @}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
135
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
136 c = string
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
137 @}
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
138 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
139 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
140
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
141 Note that when Octave prints the value of a structure that contains
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10122
diff changeset
142 other structures, only a few levels are displayed. For example:
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
143
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
144 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
145 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
146 a.b.c.d.e = 1;
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
147 a
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
148 @result{} a =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
149 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
150 b =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
151 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
152 c =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
153 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
154 1x1 struct array containing the fields:
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
155
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
156 d: 1x1 struct
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
157 @}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
158 @}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
159 @}
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
160 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
161 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
162
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
163 @noindent
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
164 This prevents long and confusing output from large deeply nested
11474
8a40037533e2 struct printing changes
John W. Eaton <jwe@octave.org>
parents: 11392
diff changeset
165 structures. The number of levels to print for nested structures may be
8a40037533e2 struct printing changes
John W. Eaton <jwe@octave.org>
parents: 11392
diff changeset
166 set with the function @code{struct_levels_to_print}, and the function
8a40037533e2 struct printing changes
John W. Eaton <jwe@octave.org>
parents: 11392
diff changeset
167 @code{print_struct_array_contents} may be used to enable printing of the
8a40037533e2 struct printing changes
John W. Eaton <jwe@octave.org>
parents: 11392
diff changeset
168 contents of structure arrays.
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
169
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
170 @DOCSTRING(struct_levels_to_print)
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
171
11474
8a40037533e2 struct printing changes
John W. Eaton <jwe@octave.org>
parents: 11392
diff changeset
172 @DOCSTRING(print_struct_array_contents)
8a40037533e2 struct printing changes
John W. Eaton <jwe@octave.org>
parents: 11392
diff changeset
173
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
174 Functions can return structures. For example, the following function
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
175 separates the real and complex parts of a matrix and stores them in two
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
176 elements of the same structure variable.
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
177
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
178 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
179 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
180 function y = f (x)
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
181 y.re = real (x);
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
182 y.im = imag (x);
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
183 endfunction
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
184 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
185 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
186
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
187 When called with a complex-valued argument, @code{f} returns the data
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
188 structure containing the real and imaginary parts of the original
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
189 function argument.
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
190
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
191 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
192 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
193 f (rand (2) + rand (2) * I)
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
194 @result{} ans =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
195 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
196 im =
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
197
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
198 0.26475 0.14828
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
199 0.18436 0.83669
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
200
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
201 re =
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
202
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
203 0.040239 0.242160
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
204 0.238081 0.402523
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
205
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
206 @}
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
207 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
208 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
209
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
210 Function return lists can include structure elements, and they may be
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10122
diff changeset
211 indexed like any other variable. For example:
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
212
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
213 @example
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
214 [ x.u, x.s(2:3,2:3), x.v ] = svd ([1, 2; 3, 4]);
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
215 x
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
216 @result{} x =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
217 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
218 u =
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
219
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
220 -0.40455 -0.91451
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
221 -0.91451 0.40455
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
222
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
223 s =
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
224
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
225 0.00000 0.00000 0.00000
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
226 0.00000 5.46499 0.00000
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
227 0.00000 0.00000 0.36597
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
228
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
229 v =
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
230
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
231 -0.57605 0.81742
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
232 -0.81742 -0.57605
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
233
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
234 @}
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
235 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
236
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
237 It is also possible to cycle through all the elements of a structure in
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
238 a loop, using a special form of the @code{for} statement
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
239 (@pxref{Looping Over Structure Elements}).
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
240
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
241 @node Structure Arrays
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
242 @subsection Structure Arrays
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
243
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
244 A structure array is a particular instance of a structure, where each of
9036
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
245 the fields of the structure is represented by a cell array. Each of
9758
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
246 these cell arrays has the same dimensions. Conceptually, a structure
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
247 array can also be seen as an array of structures with identical
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
248 fields. An example of the creation of a structure array is
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
249
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
250 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
251 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
252 x(1).a = "string1";
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
253 x(2).a = "string2";
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
254 x(1).b = 1;
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
255 x(2).b = 2;
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
256 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
257 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
258
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
259 @noindent
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
260 which creates a 2-by-1 structure array with two fields. Another way
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
261 to create a structure array is with the @code{struct} function
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
262 (@pxref{Creating Structures}). As previously, to print the value of
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
263 the structure array, you can type its name:
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
264
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
265 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
266 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
267 x
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
268 @result{} x =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
269 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
270 1x2 struct array containing the fields:
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
271
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
272 a
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
273 b
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
274 @}
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
275 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
276 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
277
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
278 Individual elements of the structure array can be returned by indexing
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
279 the variable like @code{@var{x}(1)}, which returns a structure with
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
280 two fields:
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
281
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
282 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
283 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
284 x(1)
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
285 @result{} ans =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
286 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
287 a = string1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
288 b = 1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
289 @}
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
290 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
291 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
292
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
293 Furthermore, the structure array can return a comma separated list of
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
294 field values (@pxref{Comma Separated Lists}), if indexed by one of its
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10122
diff changeset
295 own field names. For example:
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
296
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
297 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
298 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
299 x.a
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
300 @result{}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
301 ans = string1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
302 ans = string2
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
303 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
304 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
305
8584
848f7d3e589c Update the examples for structure arrays in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8541
diff changeset
306 Here is another example, using this comma separated list on the
848f7d3e589c Update the examples for structure arrays in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8541
diff changeset
307 left-hand side of an assignment:
848f7d3e589c Update the examples for structure arrays in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8541
diff changeset
308
848f7d3e589c Update the examples for structure arrays in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8541
diff changeset
309 @example
848f7d3e589c Update the examples for structure arrays in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8541
diff changeset
310 @group
14856
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14733
diff changeset
311 [x.a] = deal ("new string1", "new string2");
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
312 x(1).a
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
313 @result{} ans = new string1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
314 x(2).a
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
315 @result{} ans = new string2
8584
848f7d3e589c Update the examples for structure arrays in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8541
diff changeset
316 @end group
848f7d3e589c Update the examples for structure arrays in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8541
diff changeset
317 @end example
848f7d3e589c Update the examples for structure arrays in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8541
diff changeset
318
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10122
diff changeset
319 Just as for numerical arrays, it is possible to use vectors as indices
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10122
diff changeset
320 (@pxref{Index Expressions}):
8584
848f7d3e589c Update the examples for structure arrays in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8541
diff changeset
321
848f7d3e589c Update the examples for structure arrays in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8541
diff changeset
322 @example
848f7d3e589c Update the examples for structure arrays in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8541
diff changeset
323 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
324 x(3:4) = x(1:2);
14856
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14733
diff changeset
325 [x([1,3]).a] = deal ("other string1", "other string2");
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
326 x.a
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
327 @result{}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
328 ans = other string1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
329 ans = new string2
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
330 ans = other string2
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
331 ans = new string2
8584
848f7d3e589c Update the examples for structure arrays in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8541
diff changeset
332 @end group
848f7d3e589c Update the examples for structure arrays in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8541
diff changeset
333 @end example
848f7d3e589c Update the examples for structure arrays in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 8541
diff changeset
334
9036
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
335 The function @code{size} will return the size of the structure. For
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
336 the example above
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
337
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
338 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
339 @group
14856
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14733
diff changeset
340 size (x)
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
341 @result{} ans =
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
342
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
343 1 4
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
344 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
345 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
346
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
347 Elements can be deleted from a structure array in a similar manner to a
9036
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
348 numerical array, by assigning the elements to an empty matrix. For
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
349 example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
350
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
351 @example
9758
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
352 @group
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
353 in = struct ("call1", @{x, Inf, "last"@},
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
354 "call2", @{x, Inf, "first"@})
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
355 @result{} in =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
356 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
357 1x3 struct array containing the fields:
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
358
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
359 call1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
360 call2
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
361 @}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
362
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
363 in(1) = [];
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
364 in.call1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
365 @result{}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
366 ans = Inf
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
367 ans = last
9758
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
368 @end group
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
369 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
370
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
371 @node Creating Structures
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
372 @subsection Creating Structures
12596
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
373 @cindex dynamic naming
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
374
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17152
diff changeset
375 Besides the index operator @qcode{"."}, Octave can use dynamic naming
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17152
diff changeset
376 @qcode{"(var)"} or the @code{struct} function to create structures. Dynamic
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17152
diff changeset
377 naming uses the string value of a variable as the field name. For example:
14038
b0cdd60db5e5 doc: Grammarcheck documentation ahead of 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 12944
diff changeset
378
12596
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
379 @example
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
380 @group
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
381 a = "field2";
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
382 x.a = 1;
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
383 x.(a) = 2;
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
384 x
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
385 @result{} x =
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
386 @{
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
387 a = 1
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
388 field2 = 2
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
389 @}
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
390 @end group
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
391 @end example
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
392
15615
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
393 @noindent
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
394 Dynamic indexing also allows you to use arbitrary strings, not merely
16816
12005245b645 doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 16772
diff changeset
395 valid Octave identifiers (note that this does not work on @sc{matlab}):
15615
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
396
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
397 @example
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
398 @group
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
399 a = "long field with spaces (and funny char$)";
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
400 x.a = 1;
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
401 x.(a) = 2;
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
402 x
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
403 @result{} x =
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
404 @{
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
405 a = 1
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
406 long field with spaces (and funny char$) = 2
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
407 @}
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
408 @end group
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
409 @end example
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
410
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
411 @noindent
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
412 The warning id @code{Octave:matlab-incompatible} can be enabled to warn
17097
e7a059a9a644 doc: Use XREF as anchor prefix in documentation for clearer results in Info viewer.
Rik <rik@octave.org>
parents: 16816
diff changeset
413 about this usage. @xref{XREFwarning_ids,,warning_ids}.
15615
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
414
12596
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
415 More realistically, all of the functions that operate on strings can be used
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
416 to build the correct field name before it is entered into the data structure.
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
417
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
418 @example
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
419 @group
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
420 names = ["Bill"; "Mary"; "John"];
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
421 ages = [37; 26; 31];
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
422 for i = 1:rows (names)
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
423 database.(names(i,:)) = ages(i);
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
424 endfor
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
425 database
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
426 @result{} database =
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
427 @{
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
428 Bill = 37
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
429 Mary = 26
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
430 John = 31
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
431 @}
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
432 @end group
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
433 @end example
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
434
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
435 The third way to create structures is the @code{struct} command. @code{struct}
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
436 takes pairs of arguments, where the first argument in the pair is the fieldname
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
437 to include in the structure and the second is a scalar or cell array,
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
438 representing the values to include in the structure or structure array. For
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
439 example:
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
440
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
441 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
442 @group
7031
120f3135952f [project @ 2007-10-15 15:30:03 by jwe]
jwe
parents: 7025
diff changeset
443 struct ("field1", 1, "field2", 2)
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
444 @result{} ans =
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
445 @{
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
446 field1 = 1
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
447 field2 = 2
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
448 @}
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
449 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
450 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
451
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
452 If the values passed to @code{struct} are a mix of scalar and cell
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
453 arrays, then the scalar arguments are expanded to create a
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10122
diff changeset
454 structure array with a consistent dimension. For example:
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
455
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
456 @example
9758
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
457 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
458 s = struct ("field1", @{1, "one"@}, "field2", @{2, "two"@},
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
459 "field3", 3);
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
460 s.field1
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
461 @result{}
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
462 ans = 1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
463 ans = one
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
464
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
465 s.field2
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
466 @result{}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
467 ans = 2
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
468 ans = two
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
469
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
470 s.field3
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
471 @result{}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
472 ans = 3
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
473 ans = 3
9758
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
474 @end group
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
475 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
476
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
477 If you want to create a struct which contains a cell array as an
12596
5161d02c96b7 doc: Add help text for dynamic naming "(var)" of structure fields.
Rik <octave@nomad.inbox5.com>
parents: 12575
diff changeset
478 individual field, you must wrap it in another cell array as shown in
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
479 the following example:
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
480
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
481 @example
9758
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
482 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
483 struct ("field1", @{@{1, "one"@}@}, "field2", 2)
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
484 @result{} ans =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
485 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
486 field1 =
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17152
diff changeset
487
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
488 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
489 [1,1] = 1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
490 [1,2] = one
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
491 @}
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17152
diff changeset
492
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
493 field2 = 2
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
494 @}
9758
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
495 @end group
15615
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
496 @end example
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
497
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
498 @DOCSTRING(struct)
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
499
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
500 The function @code{isstruct} can be used to test if an object is a
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
501 structure or a structure array.
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
502
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
503 @DOCSTRING(isstruct)
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
504
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
505 @node Manipulating Structures
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
506 @subsection Manipulating Structures
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
507
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
508 Other functions that can manipulate the fields of a structure are given below.
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
509
11537
a4b0e292107f Add undocumented function nfields to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
510 @DOCSTRING(nfields)
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
511
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
512 @DOCSTRING(fieldnames)
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
513
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
514 @DOCSTRING(isfield)
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
515
15615
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
516 @DOCSTRING(setfield)
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
517
15615
808e4f13e220 doc: Update struct documentation to match new indexing rules
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14856
diff changeset
518 @DOCSTRING(getfield)
11537
a4b0e292107f Add undocumented function nfields to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
519
a4b0e292107f Add undocumented function nfields to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
520 @DOCSTRING(rmfield)
a4b0e292107f Add undocumented function nfields to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
521
a4b0e292107f Add undocumented function nfields to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
522 @DOCSTRING(orderfields)
a4b0e292107f Add undocumented function nfields to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
523
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6839
diff changeset
524 @DOCSTRING(substruct)
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6839
diff changeset
525
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6839
diff changeset
526 @node Processing Data in Structures
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6839
diff changeset
527 @subsection Processing Data in Structures
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
528
6939
46d1ad37d943 [project @ 2007-10-01 16:12:20 by jwe]
jwe
parents: 6868
diff changeset
529 The simplest way to process data in a structure is within a @code{for}
9036
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
530 loop (@pxref{Looping Over Structure Elements}). A similar effect can be
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6839
diff changeset
531 achieved with the @code{structfun} function, where a user defined
17097
e7a059a9a644 doc: Use XREF as anchor prefix in documentation for clearer results in Info viewer.
Rik <rik@octave.org>
parents: 16816
diff changeset
532 function is applied to each field of the structure.
e7a059a9a644 doc: Use XREF as anchor prefix in documentation for clearer results in Info viewer.
Rik <rik@octave.org>
parents: 16816
diff changeset
533 @xref{XREFstructfun,,structfun}.
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6839
diff changeset
534
6939
46d1ad37d943 [project @ 2007-10-01 16:12:20 by jwe]
jwe
parents: 6868
diff changeset
535 Alternatively, to process the data in a structure, the structure might
6863
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6839
diff changeset
536 be converted to another type of container before being treated.
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6839
diff changeset
537
3c64128e621c [project @ 2007-09-05 07:52:48 by dbateman]
dbateman
parents: 6839
diff changeset
538 @DOCSTRING(struct2cell)
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
539
6517
a1ec359aef37 [project @ 2007-04-11 15:14:48 by jwe]
jwe
parents: 6516
diff changeset
540 @node Cell Arrays
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
541 @section Cell Arrays
3439
3234a698073a [project @ 2000-01-14 09:51:14 by jwe]
jwe
parents:
diff changeset
542 @cindex cell arrays
3234a698073a [project @ 2000-01-14 09:51:14 by jwe]
jwe
parents:
diff changeset
543
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
544 It can be both necessary and convenient to store several variables of
9036
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
545 different size or type in one variable. A cell array is a container
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
546 class able to do just that. In general cell arrays work just like
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
547 @math{N}-dimensional arrays with the exception of the use of @samp{@{}
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
548 and @samp{@}} as allocation and indexing operators.
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
549
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
550 @menu
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
551 * Basic Usage of Cell Arrays::
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
552 * Creating Cell Arrays::
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
553 * Indexing Cell Arrays::
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
554 * Cell Arrays of Strings::
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
555 * Processing Data in Cell Arrays::
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
556 @end menu
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
557
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
558 @node Basic Usage of Cell Arrays
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
559 @subsection Basic Usage of Cell Arrays
12175
2090995ca588 Correct en-dash,em-dash instances in docstrings.
Rik <octave@nomad.inbox5.com>
parents: 11537
diff changeset
560 @opindex @{
2090995ca588 Correct en-dash,em-dash instances in docstrings.
Rik <octave@nomad.inbox5.com>
parents: 11537
diff changeset
561 @opindex @}
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
562 As an example, the following code creates a cell array containing a
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
563 string and a 2-by-2 random matrix
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
564
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
565 @example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
566 c = @{"a string", rand(2, 2)@};
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
567 @end example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
568
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
569 @noindent
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
570 To access the elements of a cell array, it can be indexed with the @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
571 and @} operators. Thus, the variable created in the previous example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
572 can be indexed like this:
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
573
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
574 @example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
575 @group
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
576 c@{1@}
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
577 @result{} ans = a string
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
578 @end group
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
579 @end example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
580
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
581 @noindent
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
582 As with numerical arrays several elements of a cell array can be
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
583 extracted by indexing with a vector of indexes
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
584
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
585 @example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
586 @group
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
587 c@{1:2@}
12944
1acb639204d0 Fix incorrect documentation for cs-lists from cell arrays.
Ben Abbott <bpabbott@mac.com>
parents: 12923
diff changeset
588 @result{} ans = a string
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
589 @result{} ans =
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17152
diff changeset
590
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
591 0.593993 0.627732
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
592 0.377037 0.033643
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
593 @end group
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
594 @end example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
595
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
596 The indexing operators can also be used to insert or overwrite elements
9036
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
597 of a cell array. The following code inserts the scalar 3 on the
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
598 third place of the previously created cell array
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
599
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
600 @example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
601 @group
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
602 c@{3@} = 3
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
603 @result{} c =
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17152
diff changeset
604
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
605 @{
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
606 [1,1] = a string
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
607 [1,2] =
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17152
diff changeset
608
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
609 0.593993 0.627732
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
610 0.377037 0.033643
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17152
diff changeset
611
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
612 [1,3] = 3
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
613 @}
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
614 @end group
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
615 @end example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
616
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
617 Details on indexing cell arrays are explained in @ref{Indexing Cell Arrays}.
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
618
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
619 In general nested cell arrays are displayed hierarchically as in the
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
620 previous example. In some circumstances it makes sense to reference
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
621 them by their index, and this can be performed by the @code{celldisp}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
622 function.
6868
975fcdfb0d2d [project @ 2007-09-06 16:34:29 by dbateman]
dbateman
parents: 6863
diff changeset
623
975fcdfb0d2d [project @ 2007-09-06 16:34:29 by dbateman]
dbateman
parents: 6863
diff changeset
624 @DOCSTRING(celldisp)
975fcdfb0d2d [project @ 2007-09-06 16:34:29 by dbateman]
dbateman
parents: 6863
diff changeset
625
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
626 To test if an object is a cell array, use the @code{iscell}
9758
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
627 function. For example:
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
628
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
629 @example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
630 @group
14856
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14733
diff changeset
631 iscell (c)
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
632 @result{} ans = 1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
633
14856
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14733
diff changeset
634 iscell (3)
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
635 @result{} ans = 0
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
636
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
637 @end group
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
638 @end example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
639
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
640 @DOCSTRING(iscell)
6516
ce5caa673642 [project @ 2007-04-11 14:26:39 by jwe]
jwe
parents: 6514
diff changeset
641
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
642 @node Creating Cell Arrays
17152
f2a8592b8fbd doc: Shorten some long subsection names in Manual.
Rik <rik@octave.org>
parents: 17097
diff changeset
643 @subsection Creating Cell Arrays
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
644
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
645 The introductory example (@pxref{Basic Usage of Cell Arrays}) showed
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
646 how to create a cell array containing currently available variables.
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
647 In many situations, however, it is useful to create a cell array and
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
648 then fill it with data.
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
649
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
650 The @code{cell} function returns a cell array of a given size, containing
9036
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
651 empty matrices. This function is similar to the @code{zeros}
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
652 function for creating new numerical arrays. The following example creates
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
653 a 2-by-2 cell array containing empty matrices
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
654
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
655 @example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
656 @group
14856
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14733
diff changeset
657 c = cell (2,2)
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
658 @result{} c =
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 17152
diff changeset
659
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
660 @{
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
661 [1,1] = [](0x0)
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
662 [2,1] = [](0x0)
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
663 [1,2] = [](0x0)
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
664 [2,2] = [](0x0)
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
665 @}
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
666 @end group
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
667 @end example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
668
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10122
diff changeset
669 Just like numerical arrays, cell arrays can be multi-dimensional. The
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
670 @code{cell} function accepts any number of positive integers to describe
9036
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
671 the size of the returned cell array. It is also possible to set the size
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
672 of the cell array through a vector of positive integers. In the
8347
fa78cb8d8a5c corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents: 8176
diff changeset
673 following example two cell arrays of equal size are created, and the size
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
674 of the first one is displayed
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
675
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
676 @example
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9036
diff changeset
677 @group
14856
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14733
diff changeset
678 c1 = cell (3, 4, 5);
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14733
diff changeset
679 c2 = cell ( [3, 4, 5] );
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14733
diff changeset
680 size (c1)
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
681 @result{} ans =
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
682 3 4 5
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9036
diff changeset
683 @end group
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
684 @end example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
685
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
686 @noindent
17097
e7a059a9a644 doc: Use XREF as anchor prefix in documentation for clearer results in Info viewer.
Rik <rik@octave.org>
parents: 16816
diff changeset
687 As can be seen, the @ref{XREFsize,,size} function also works
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
688 for cell arrays. As do other functions describing the size of an
17097
e7a059a9a644 doc: Use XREF as anchor prefix in documentation for clearer results in Info viewer.
Rik <rik@octave.org>
parents: 16816
diff changeset
689 object, such as @ref{XREFlength,,length}, @ref{XREFnumel,, numel},
e7a059a9a644 doc: Use XREF as anchor prefix in documentation for clearer results in Info viewer.
Rik <rik@octave.org>
parents: 16816
diff changeset
690 @ref{XREFrows,,rows}, and @ref{XREFcolumns,,columns}.
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
691
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
692 @DOCSTRING(cell)
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
693
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9036
diff changeset
694 As an alternative to creating empty cell arrays, and then filling them, it
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
695 is possible to convert numerical arrays into cell arrays using the
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9758
diff changeset
696 @code{num2cell}, @code{mat2cell} and @code{cellslices} functions.
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
697
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
698 @DOCSTRING(num2cell)
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
699
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
700 @DOCSTRING(mat2cell)
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
701
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9758
diff changeset
702 @DOCSTRING(cellslices)
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9758
diff changeset
703
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
704 @node Indexing Cell Arrays
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
705 @subsection Indexing Cell Arrays
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
706
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
707 As shown in @pxref{Basic Usage of Cell Arrays} elements can be
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
708 extracted from cell arrays using the @samp{@{} and @samp{@}}
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
709 operators. If you want to extract or access subarrays which are still
9758
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
710 cell arrays, you need to use the @samp{(} and @samp{)} operators. The
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
711 following example illustrates the difference:
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
712
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
713 @example
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
714 @group
14733
baa10bd6f8df doc: Change cell contents for clarity
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
715 c = @{"1", "2", "3"; "x", "y", "z"; "4", "5", "6"@};
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
716 c@{2,3@}
14733
baa10bd6f8df doc: Change cell contents for clarity
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
717 @result{} ans = z
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
718
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
719 c(2,3)
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
720 @result{} ans =
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
721 @{
14733
baa10bd6f8df doc: Change cell contents for clarity
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
722 [1,1] = z
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
723 @}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
724 @end group
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
725 @end example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
726
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
727 @noindent So with @samp{@{@}} you access elements of a cell
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
728 array, while with @samp{()} you access a sub array of a cell
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
729 array.
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
730
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
731 Using the @samp{(} and @samp{)} operators, indexing works for cell
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10122
diff changeset
732 arrays like for multi-dimensional arrays. As an example, all the rows
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
733 of the first and third column of a cell array can be set to @code{0}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
734 with the following command:
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
735
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
736 @example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
737 @group
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
738 c(:, [1, 3]) = @{0@}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
739 @result{} =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
740 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
741 [1,1] = 0
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
742 [2,1] = 0
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
743 [3,1] = 0
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
744 [1,2] = 2
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
745 [2,2] = 10
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
746 [3,2] = 20
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
747 [1,3] = 0
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
748 [2,3] = 0
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
749 [3,3] = 0
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
750 @}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
751 @end group
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
752 @end example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
753
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
754 Note, that the above can also be achieved like this:
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
755
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
756 @example
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
757 c(:, [1, 3]) = 0;
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
758 @end example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
759
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
760 @noindent Here, the scalar @samp{0} is automatically promoted to
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
761 cell array @samp{@{0@}} and then assigned to the subarray of @code{c}.
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
762
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
763 To give another example for indexing cell arrays with @samp{()}, you
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
764 can exchange the first and the second row of a cell array as in the
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
765 following command:
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
766
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
767 @example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
768 @group
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
769 c = @{1, 2, 3; 4, 5, 6@};
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
770 c([1, 2], :) = c([2, 1], :)
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
771 @result{} =
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
772 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
773 [1,1] = 4
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
774 [2,1] = 1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
775 [1,2] = 5
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
776 [2,2] = 2
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
777 [1,3] = 6
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
778 [2,3] = 3
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
779 @}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
780 @end group
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
781 @end example
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
782
6518
952c8b00525e [project @ 2007-04-11 20:50:22 by jwe]
jwe
parents: 6517
diff changeset
783 Accessing multiple elements of a cell array with the @samp{@{} and
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
784 @samp{@}} operators will result in a comma-separated list of all the
9758
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
785 requested elements (@pxref{Comma Separated Lists}). Using the
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
786 @samp{@{} and @samp{@}} operators the first two rows in the above
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
787 example can be swapped back like this:
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
788
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
789 @example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
790 @group
14856
c3fd61c59e9c maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents: 14733
diff changeset
791 [c@{[1,2], :@}] = deal (c@{[2, 1], :@})
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
792 @result{} =
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
793 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
794 [1,1] = 1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
795 [2,1] = 4
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
796 [1,2] = 2
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
797 [2,2] = 5
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
798 [1,3] = 3
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
799 [2,3] = 6
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
800 @}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
801 @end group
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
802 @end example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
803
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
804 As for struct arrays and numerical arrays, the empty matrix @samp{[]}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
805 can be used to delete elements from a cell array:
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
806
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
807 @example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
808 @group
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
809 x = @{"1", "2"; "3", "4"@};
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
810 x(1, :) = []
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
811 @result{} x =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
812 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
813 [1,1] = 3
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
814 [1,2] = 4
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
815 @}
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
816 @end group
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
817 @end example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
818
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
819 The following example shows how to just remove the contents of cell
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
820 array elements but not delete the space for them:
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
821
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
822 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
823 @group
7031
120f3135952f [project @ 2007-10-15 15:30:03 by jwe]
jwe
parents: 7025
diff changeset
824 x = @{"1", "2"; "3", "4"@};
6839
40ad39648884 [project @ 2007-08-28 15:28:13 by dbateman]
dbateman
parents: 6837
diff changeset
825 x@{1, :@} = []
40ad39648884 [project @ 2007-08-28 15:28:13 by dbateman]
dbateman
parents: 6837
diff changeset
826 @result{} x =
40ad39648884 [project @ 2007-08-28 15:28:13 by dbateman]
dbateman
parents: 6837
diff changeset
827 @{
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
828 [1,1] = [](0x0)
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
829 [2,1] = 3
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
830 [1,2] = [](0x0)
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
831 [2,2] = 4
6839
40ad39648884 [project @ 2007-08-28 15:28:13 by dbateman]
dbateman
parents: 6837
diff changeset
832 @}
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
833 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
834 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
835
12575
d0b799dafede Grammarcheck files for 3.4.1 release.
Rik <octave@nomad.inbox5.com>
parents: 12535
diff changeset
836 The indexing operations operate on the cell array and not on the objects
12535
1eb430d9a1b9 Add cellindexmat function to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12175
diff changeset
837 within the cell array. By contrast, @code{cellindexmat} applies matrix indexing
1eb430d9a1b9 Add cellindexmat function to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12175
diff changeset
838 to the objects within each cell array entry and returns the requested values.
1eb430d9a1b9 Add cellindexmat function to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12175
diff changeset
839
1eb430d9a1b9 Add cellindexmat function to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12175
diff changeset
840 @DOCSTRING(cellindexmat)
1eb430d9a1b9 Add cellindexmat function to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12175
diff changeset
841
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
842 @node Cell Arrays of Strings
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
843 @subsection Cell Arrays of Strings
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
844
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
845 One common use of cell arrays is to store multiple strings in the same
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
846 variable. It is also possible to store multiple strings in a
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
847 character matrix by letting each row be a string. This, however,
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
848 introduces the problem that all strings must be of equal length.
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
849 Therefore, it is recommended to use cell arrays to store multiple
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
850 strings. For cases, where the character matrix representation is required
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
851 for an operation, there are several functions that convert a cell
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
852 array of strings to a character array and back. @code{char} and
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
853 @code{strvcat} convert cell arrays to a character array
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
854 (@pxref{Concatenating Strings}), while the function @code{cellstr}
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
855 converts a character array to a cell array of strings:
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
856
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
857 @example
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9036
diff changeset
858 @group
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
859 a = ["hello"; "world"];
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
860 c = cellstr (a)
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
861 @result{} c =
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
862 @{
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
863 [1,1] = hello
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
864 [2,1] = world
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
865 @}
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9036
diff changeset
866 @end group
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
867 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
868
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
869 @DOCSTRING(cellstr)
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
870
8828
8463d1a2e544 Doc fixes.
Brian Gough <bjg@network-theory.co.uk>
parents: 8584
diff changeset
871 One further advantage of using cell arrays to store multiple strings is
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
872 that most functions for string manipulations included with Octave
9036
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
873 support this representation. As an example, it is possible to compare
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
874 one string with many others using the @code{strcmp} function. If one of
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
875 the arguments to this function is a string and the other is a cell array
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
876 of strings, each element of the cell array will be compared to the string
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
877 argument:
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
878
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
879 @example
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9036
diff changeset
880 @group
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
881 c = @{"hello", "world"@};
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
882 strcmp ("hello", c)
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
883 @result{} ans =
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
884 1 0
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9036
diff changeset
885 @end group
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
886 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
887
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
888 @noindent
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
889 The following string functions support cell arrays of strings:
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
890 @code{char}, @code{strvcat}, @code{strcat} (@pxref{Concatenating
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
891 Strings}), @code{strcmp}, @code{strncmp}, @code{strcmpi},
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
892 @code{strncmpi} (@pxref{Comparing Strings}), @code{str2double},
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
893 @code{deblank}, @code{strtrim}, @code{strtrunc}, @code{strfind},
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
894 @code{strmatch}, , @code{regexp}, @code{regexpi} (@pxref{Manipulating
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
895 Strings}) and @code{str2double} (@pxref{String Conversions}).
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
896
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
897 The function @code{iscellstr} can be used to test if an object is a
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
898 cell array of strings.
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
899
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
900 @DOCSTRING(iscellstr)
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
901
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
902 @node Processing Data in Cell Arrays
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
903 @subsection Processing Data in Cell Arrays
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
904
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
905 Data that is stored in a cell array can be processed in several ways
9036
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
906 depending on the actual data. The simplest way to process that data
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
907 is to iterate through it using one or more @code{for} loops. The same
8828
8463d1a2e544 Doc fixes.
Brian Gough <bjg@network-theory.co.uk>
parents: 8584
diff changeset
908 idea can be implemented more easily through the use of the @code{cellfun}
8493
2f5a2c58c15e [docs] user specified => user-specified
Brian Gough <bjg@gnu.org>
parents: 8372
diff changeset
909 function that calls a user-specified function on all elements of a cell
17097
e7a059a9a644 doc: Use XREF as anchor prefix in documentation for clearer results in Info viewer.
Rik <rik@octave.org>
parents: 16816
diff changeset
910 array. @xref{XREFcellfun,,cellfun}.
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
911
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
912 An alternative is to convert the data to a different container, such as
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
913 a matrix or a data structure. Depending on the data this is possible
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
914 using the @code{cell2mat} and @code{cell2struct} functions.
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
915
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
916 @DOCSTRING(cell2mat)
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
917
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
918 @DOCSTRING(cell2struct)
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
919
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
920 @node Comma Separated Lists
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
921 @section Comma Separated Lists
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
922 @cindex comma separated lists
8541
d2cf983bdc9d container.txi: define cs-list
John W. Eaton <jwe@octave.org>
parents: 8493
diff changeset
923 @cindex cs-lists
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
924
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
925 Comma separated lists @footnote{Comma-separated lists are also sometimes
8541
d2cf983bdc9d container.txi: define cs-list
John W. Eaton <jwe@octave.org>
parents: 8493
diff changeset
926 informally referred to as @dfn{cs-lists}.} are the basic argument type
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
927 to all Octave functions - both for input and return arguments. In the
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
928 example
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
929
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
930 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
931 max (@var{a}, @var{b})
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
932 @end example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
933
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
934 @noindent
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
935 @samp{@var{a}, @var{b}} is a comma separated list. Comma separated lists
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
936 can appear on both the right and left hand side of an assignment. For
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
937 example
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
938
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
939 @example
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9036
diff changeset
940 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
941 x = [1 0 1 0 0 1 1; 0 0 0 0 0 0 7];
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
942 [@var{i}, @var{j}] = find (@var{x}, 2, "last");
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
943 @end group
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
944 @end example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
945
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
946 @noindent
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
947 Here, @samp{@var{x}, 2, "last"} is a comma separated list constituting
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
948 the input arguments of @code{find}. @code{find} returns a comma
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
949 separated list of output arguments which is assigned element by
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
950 element to the comma separated list @samp{@var{i}, @var{j}}.
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
951
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
952 Another example of where comma separated lists are used is in the
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
953 creation of a new array with @code{[]} (@pxref{Matrices}) or the
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
954 creation of a cell array with @code{@{@}} (@pxref{Basic Usage of Cell
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
955 Arrays}). In the expressions
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
956
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
957 @example
9758
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
958 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
959 a = [1, 2, 3, 4];
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
960 c = @{4, 5, 6, 7@};
9758
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
961 @end group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
962 @end example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
963
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
964 @noindent
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
965 both @samp{1, 2, 3, 4} and @samp{4, 5, 6, 7} are comma separated lists.
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
966
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
967 Comma separated lists cannot be directly manipulated by the
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
968 user. However, both structure arrays and cell arrays can be converted
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
969 into comma separated lists, and thus used in place of explicitly
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
970 written comma separated lists. This feature is useful in many ways,
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
971 as will be shown in the following subsections.
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
972
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
973 @menu
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
974 * Comma Separated Lists Generated from Cell Arrays::
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
975 * Comma Separated Lists Generated from Structure Arrays::
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
976 @end menu
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
977
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
978 @node Comma Separated Lists Generated from Cell Arrays
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
979 @subsection Comma Separated Lists Generated from Cell Arrays
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
980
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
981 As has been mentioned above (@pxref{Indexing Cell Arrays}), elements
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
982 of a cell array can be extracted into a comma separated list with the
9758
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
983 @code{@{} and @code{@}} operators. By surrounding this list with
09da0bd91412 Periodic grammar check of Octave documentation files to ensure common format
Rik <rdrider0-list@yahoo.com>
parents: 9312
diff changeset
984 @code{[} and @code{]}, it can be concatenated into an array. For example:
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
985
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
986 @example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
987 @group
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
988 a = @{1, [2, 3], 4, 5, 6@};
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
989 b = [a@{1:4@}]
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
990 @result{} b =
12923
b7e526ce7a3a Fix incorrect example output for concatenating cs-lists from cells
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12596
diff changeset
991 1 2 3 4 5
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9036
diff changeset
992 @end group
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
993 @end example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
994
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
995 Similarly, it is possible to create a new cell array containing cell
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
996 elements selected with @code{@{@}}. By surrounding the list with
8828
8463d1a2e544 Doc fixes.
Brian Gough <bjg@network-theory.co.uk>
parents: 8584
diff changeset
997 @samp{@{} and @samp{@}} a new cell array will be created, as the
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
998 following example illustrates:
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
999
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1000 @example
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9036
diff changeset
1001 @group
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1002 a = @{1, rand(2, 2), "three"@};
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1003 b = @{ a@{ [1, 3] @} @}
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1004 @result{} b =
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1005 @{
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1006 [1,1] = 1
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1007 [1,2] = three
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1008 @}
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9036
diff changeset
1009 @end group
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1010 @end example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1011
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1012 Furthermore, cell elements (accessed by @code{@{@}}) can be passed
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1013 directly to a function. The list of elements from the cell array will
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1014 be passed as an argument list to a given function as if it is called
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1015 with the elements as individual arguments. The two calls to
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1016 @code{printf} in the following example are identical but the latter is
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1017 simpler and can handle cell arrays of an arbitrary size:
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1018
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1019 @example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1020 @group
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1021 c = @{"GNU", "Octave", "is", "Free", "Software"@};
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1022 printf ("%s ", c@{1@}, c@{2@}, c@{3@}, c@{4@}, c@{5@});
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
1023 @print{} GNU Octave is Free Software
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1024 printf ("%s ", c@{:@});
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
1025 @print{} GNU Octave is Free Software
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1026 @end group
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1027 @end example
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1028
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1029 If used on the left-hand side of an assignment, a comma separated list
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
1030 generated with @code{@{@}} can be assigned to. An example is
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1031
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1032 @example
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9036
diff changeset
1033 @group
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1034 in@{1@} = [10, 20, 30, 40, 50, 60, 70, 80, 90];
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1035 in@{2@} = inf;
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1036 in@{3@} = "last";
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1037 in@{4@} = "first";
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1038 out = cell (4, 1);
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1039 [out@{1:3@}] = find (in@{1 : 3@});
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1040 [out@{4:6@}] = find (in@{[1, 2, 4]@})
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1041 @result{} out =
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1042 @{
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1043 [1,1] = 1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1044 [2,1] = 9
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1045 [3,1] = 90
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1046 [4,1] = 1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1047 [3,1] = 1
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1048 [4,1] = 10
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1049 @}
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9036
diff changeset
1050 @end group
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1051 @end example
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1052
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1053
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1054 @node Comma Separated Lists Generated from Structure Arrays
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1055 @subsection Comma Separated Lists Generated from Structure Arrays
6939
46d1ad37d943 [project @ 2007-10-01 16:12:20 by jwe]
jwe
parents: 6868
diff changeset
1056 Structure arrays can equally be used to create comma separated
9036
58604c45ca74 Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
1057 lists. This is done by addressing one of the fields of a structure
10828
322f43e0e170 Grammarcheck .txi documentation files.
Rik <octave@nomad.inbox5.com>
parents: 10122
diff changeset
1058 array. For example:
6514
5ef6f71974db [project @ 2007-04-11 14:15:40 by jwe]
jwe
parents: 6502
diff changeset
1059
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
1060 @example
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
1061 @group
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
1062 x = ceil (randn (10, 1));
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
1063 in = struct ("call1", @{x, 3, "last"@},
9312
0f7480d07f6a update documentation of container types in container.txi
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 9209
diff changeset
1064 "call2", @{x, inf, "first"@});
7031
120f3135952f [project @ 2007-10-15 15:30:03 by jwe]
jwe
parents: 7025
diff changeset
1065 out = struct ("call1", cell (2, 1), "call2", cell (2, 1));
6837
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
1066 [out.call1] = find (in.call1);
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
1067 [out.call2] = find (in.call2);
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
1068 @end group
7eefeed173ea [project @ 2007-08-27 20:20:55 by dbateman]
dbateman
parents: 6778
diff changeset
1069 @end example