Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 3e60ff9d4d6f58c8fbd17208f14089fa > files > 269

octave-doc-3.2.3-3mdv2010.0.i586.rpm

<html lang="en">
<head>
<title>Manipulating Structures - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Data-Structures.html#Data-Structures" title="Data Structures">
<link rel="prev" href="Creating-Structures.html#Creating-Structures" title="Creating Structures">
<link rel="next" href="Processing-Data-in-Structures.html#Processing-Data-in-Structures" title="Processing Data in Structures">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Manipulating-Structures"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Processing-Data-in-Structures.html#Processing-Data-in-Structures">Processing Data in Structures</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Creating-Structures.html#Creating-Structures">Creating Structures</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Data-Structures.html#Data-Structures">Data Structures</a>
<hr>
</div>

<h4 class="subsection">6.1.4 Manipulating Structures</h4>

<p>Other functions that can manipulate the fields of a structure are given below.

<!-- ov-struct.cc -->
   <p><a name="doc_002drmfield"></a>

<div class="defun">
&mdash; Built-in Function:  <b>rmfield</b> (<var>s, f</var>)<var><a name="index-rmfield-375"></a></var><br>
<blockquote><p>Remove field <var>f</var> from the structure <var>s</var>.  If <var>f</var> is a
cell array of character strings or a character array, remove the
named fields. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dcellstr.html#doc_002dcellstr">cellstr</a>, <a href="doc_002discellstr.html#doc_002discellstr">iscellstr</a>, <a href="doc_002dsetfield.html#doc_002dsetfield">setfield</a>. 
</p></blockquote></div>

<!-- ./miscellaneous/setfield.m -->
   <p><a name="doc_002dsetfield"></a>

<div class="defun">
&mdash; Function File: [<var>k1</var>, <small class="dots">...</small>, <var>v1</var>] = <b>setfield</b> (<var>s, k1, v1, <small class="dots">...</small></var>)<var><a name="index-setfield-376"></a></var><br>
<blockquote><p>Set field members in a structure.

     <pre class="example">          oo(1,1).f0 = 1;
          oo = setfield (oo, {1,2}, "fd", {3}, "b", 6);
          oo(1,2).fd(3).b == 6
          &rArr; ans = 1
</pre>
        <p>Note that this function could be written

     <pre class="example">          i1 = {1,2}; i2 = "fd"; i3 = {3}; i4 = "b";
          oo(i1{:}).(i2)(i3{:}).(i4) == 6;
</pre>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dgetfield.html#doc_002dgetfield">getfield</a>, <a href="doc_002drmfield.html#doc_002drmfield">rmfield</a>, <a href="doc_002disfield.html#doc_002disfield">isfield</a>, <a href="doc_002disstruct.html#doc_002disstruct">isstruct</a>, <a href="doc_002dfieldnames.html#doc_002dfieldnames">fieldnames</a>, <a href="doc_002dstruct.html#doc_002dstruct">struct</a>. 
</p></blockquote></div>

<!-- ./miscellaneous/orderfields.m -->
   <p><a name="doc_002dorderfields"></a>

<div class="defun">
&mdash; Function File: [<var>t</var>, <var>p</var>] = <b>orderfields</b> (<var>s1, s2</var>)<var><a name="index-orderfields-377"></a></var><br>
<blockquote><p>Return a struct with fields arranged alphabetically or as specified
by <var>s2</var> and a corresponding permutation vector.

        <p>Given one struct, arrange field names in <var>s1</var> alphabetically.

        <p>Given two structs, arrange field names in <var>s1</var> as they appear
in <var>s2</var>.  The second argument may also specify the order in
a permutation vector or a cell array of strings.

     <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dgetfield.html#doc_002dgetfield">getfield</a>, <a href="doc_002drmfield.html#doc_002drmfield">rmfield</a>, <a href="doc_002disfield.html#doc_002disfield">isfield</a>, <a href="doc_002disstruct.html#doc_002disstruct">isstruct</a>, <a href="doc_002dfieldnames.html#doc_002dfieldnames">fieldnames</a>, <a href="doc_002dstruct.html#doc_002dstruct">struct</a>. 
</p></blockquote></div>

<!-- ov-struct.cc -->
   <p><a name="doc_002dfieldnames"></a>

<div class="defun">
&mdash; Built-in Function:  <b>fieldnames</b> (<var>struct</var>)<var><a name="index-fieldnames-378"></a></var><br>
<blockquote><p>Return a cell array of strings naming the elements of the structure
<var>struct</var>.  It is an error to call <code>fieldnames</code> with an
argument that is not a structure. 
</p></blockquote></div>

<!-- ov-struct.cc -->
   <p><a name="doc_002disfield"></a>

<div class="defun">
&mdash; Built-in Function:  <b>isfield</b> (<var>expr, name</var>)<var><a name="index-isfield-379"></a></var><br>
<blockquote><p>Return true if the expression <var>expr</var> is a structure and it includes an
element named <var>name</var>.  The first argument must be a structure and
the second must be a string. 
</p></blockquote></div>

<!-- ./miscellaneous/getfield.m -->
   <p><a name="doc_002dgetfield"></a>

<div class="defun">
&mdash; Function File: [<var>v1</var>, <small class="dots">...</small>] = <b>getfield</b> (<var>s, key, <small class="dots">...</small></var>)<var><a name="index-getfield-380"></a></var><br>
<blockquote><p>Extract fields from a structure.  For example

     <pre class="example">          ss(1,2).fd(3).b = 5;
          getfield (ss, {1,2}, "fd", {3}, "b")
          &rArr; ans = 5
</pre>
        <p>Note that the function call in the previous example is equivalent to
the expression

     <pre class="example">          i1 = {1,2}; i2 = "fd"; i3 = {3}; i4= "b";
          ss(i1{:}).(i2)(i3{:}).(i4)
</pre>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dsetfield.html#doc_002dsetfield">setfield</a>, <a href="doc_002drmfield.html#doc_002drmfield">rmfield</a>, <a href="doc_002disfield.html#doc_002disfield">isfield</a>, <a href="doc_002disstruct.html#doc_002disstruct">isstruct</a>, <a href="doc_002dfieldnames.html#doc_002dfieldnames">fieldnames</a>, <a href="doc_002dstruct.html#doc_002dstruct">struct</a>. 
</p></blockquote></div>

<!-- ./miscellaneous/substruct.m -->
   <p><a name="doc_002dsubstruct"></a>

<div class="defun">
&mdash; Function File:  <b>substruct</b> (<var>type, subs, <small class="dots">...</small></var>)<var><a name="index-substruct-381"></a></var><br>
<blockquote><p>Create a subscript structure for use with <code>subsref</code> or
<code>subsasgn</code>. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dsubsref.html#doc_002dsubsref">subsref</a>, <a href="doc_002dsubsasgn.html#doc_002dsubsasgn">subsasgn</a>. 
</p></blockquote></div>

   </body></html>