1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2006-2008 - INRIA
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 * Copyright (C) 2020 - Samuel GOUGEON
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
16 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
17 xmlns:svg="http://www.w3.org/2000/svg" xmlns:db="http://docbook.org/ns/docbook"
18 xmlns:scilab="http://www.scilab.org" xml:lang="ja" xml:id="setfield">
20 <refname>setfield</refname>
21 <refpurpose>mlist, tlist, またはlistの要素の値を変更する</refpurpose>
25 <synopsis>uL = setfield(a, v, L)</synopsis>
33 <literal>list</literal>, <literal>tlist</literal>,
34 または<literal>mlist</literal>リスト:コンポーネントを変更する必要があるリスト.
41 変更するコンポーネントのアドレス. 文字列として指定されたフィールド名,
42 または正の整数として指定されたインデックスのいずれかになります.
43 詳細については, <link linkend="insertion">insertion</link>をご覧ください.
50 任意のScilabオブジェクト:割り当てる値
66 <literal>L=setfield(a,v,L)</literal> addresses and changes the
67 i<superscript>th</superscript> element of a list, in a unified way
68 over lists, tlists and mlists.
71 For simple lists and for tlists, <literal>L=setfield(a,v,L)</literal>
72 is equivalent to <literal>L(a)=v</literal>, that is simpler and should be preferred.
73 The same stands for any mlist if the address <varname>a</varname> is a
77 However, for any mlist L, if <literal>i</literal> is an index, the insertion
78 <literal>L(i)=v</literal> is not predefined, in order to let the user define
79 an overload implementing a matrix-oriented insertion, if required.
80 Yet <literal>setfield(i,v,L)</literal> is always defined, with the same meaning as
81 for other list and tlist types.
87 For a tlist, <literal>setfield(3, v, T)</literal> is equivalent to
88 <literal>T(3)=v</literal> :
90 <programlisting role="example"><![CDATA[
91 T = tlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
92 // The insertion is predefined:
96 T = setfield(3, [%f %t %f], T);
100 --> T = tlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
101 --> // The insertion is predefined:
102 --> T(3) = [%t %t %f];
107 --> T = setfield(3, [%f %t %f], T);
113 For a mlist, there is no predefined indexed insertion routine, to let
114 the user define a matrix-oriented insertion overload if required.
116 <programlisting role="example"><![CDATA[
117 M = mlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
120 M(3) = [%f %t %f]; // => error
122 // But a raw direct insertion with setfield() is always possible:
123 M = setfield(3, [%t %f %t], M);
127 --> M = mlist(['V','a','b'], [%z (1-%z) %z^2], [%f %t %t]);
128 --> M.b = [%t %t %t];
129 --> M.b // OK, while ...
133 --> M(3) = [%f %t %f]; // => error
134 Function not defined for given argument type(s),
135 check arguments or define function %b_i_V for overloading.
137 --> // But a raw direct insertion with setfield() is always possible:
138 --> M = setfield(3, [%t %f %t], M);
144 <refsection role="see also">
146 <simplelist type="inline">
148 <link linkend="insertion">insertion</link>
151 <link linkend="getfield">getfield</link>
159 <revnumber>6.0.0</revnumber>
163 The updated list is now returned, instead of being changed "in place".
166 setfield() can no longer be used for cells arrays.