11b79d35458df8f6b2cd4f4451691367c5c9f361
[scilab.git] / scilab / modules / elementary_functions / help / ja_JP / elementarymatrices / ndgrid.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"  xml:id="ndgrid" xml:lang="ja">
4     
5     <refnamediv>
6         
7         <refname>ndgrid</refname>
8         
9         <refpurpose>
10             
11             多次元関数評価用グリッドの配列
12             
13         </refpurpose>
14         
15     </refnamediv>
16     
17     <refsynopsisdiv>
18         
19         <title>呼び出し手順</title>
20         
21         <synopsis>[X, Y] = ndgrid(x,y)
22             
23             [X, Y, Z] = ndgrid(x,y,z)
24             
25             [X, Y, Z, T] = ndgrid(x,y,z,t)
26             
27             [X1, X2, ..., Xm] = ndgrid(x1,x2,...,xm)
28             
29         </synopsis>
30         
31     </refsynopsisdiv>
32     
33     <refsection>
34         
35         <title>引数</title>
36         
37         <variablelist>
38             
39             <varlistentry>
40                 
41                 <term>x, y, z, ...</term>
42                 
43                 <listitem>
44                     
45                     <para>ベクトル</para>
46                     
47                 </listitem>
48                 
49             </varlistentry>
50             
51             <varlistentry>
52                 
53                 <term>X, Y, Z, ...</term>
54                 
55                 <listitem>
56                     
57                     <para>
58                         
59                         入力引数が2個の場合は行列,
60                         
61                         それ以外の場合はハイパー行列
62                         
63                     </para>
64                     
65                 </listitem>
66                 
67             </varlistentry>
68             
69         </variablelist>
70         
71     </refsection>
72     
73     <refsection>
74         
75         <title>説明</title>
76         
77         <para>
78             
79             この関数はユーティリティルーチンで,
80             
81             2, 3, ..., n次元のグリッド上で関数の評価を行う
82             
83             ための配列を作成する際に便利です.
84             
85             例えば, 2次元の場合, グリッドは
86             
87             長さ nx および nyの
88             
89             2つのベクトル
90             
91             <literal>x</literal> および <literal> y</literal>
92             
93             で定義され,
94             
95             <emphasis>i=1,..,nx</emphasis> および <emphasis>j=1,..,ny</emphasis>
96             
97             として,座標<emphasis>(x(i),y(j))</emphasis>となります.
98             
99             そのグリッド上で (例えば<emphasis>f</emphasis>のような)関数の評価を
100             
101             行うことになります.
102             
103             この場合,この関数は,以下のような大きさ<emphasis>nx x ny</emphasis>の
104             
105             2つの行列<literal>X,Y</literal>を計算します :
106             
107         </para>
108         
109         <programlisting role="no-scilab-exec"><![CDATA[ 
110 X(i,j) = x(i)   for all i in [1,nx]
111 Y(i,j) = y(j)       and j in [1,ny]
112  ]]></programlisting>
113         
114         <para>
115             
116             評価は,<literal>Z=f(X,Y)</literal>で行うことができます.
117             
118             (ベクトル引数で<literal>f</literal>を評価するようコードが
119             
120             作成されている場合,
121             
122             <literal>*</literal>,
123             
124             <literal>/</literal> および <literal>^</literal>の部分に
125             
126             要素毎の演算 <literal>.*</literal>, <literal>./</literal> および
127             
128             <literal>.^</literal>を使用することにより,(一般に)動作します..
129             
130         </para>
131         
132         <para>
133             
134             3次元の場合, 長さ nx, ny および nzの3個のベクトル<literal>x,y,z</literal>
135             
136             を指定し,
137             
138             <literal>X,Y,Z</literal>は以下のように大きさ
139             
140             <emphasis>nx x ny x nz</emphasis>のハイパー行列となります :
141             
142         </para>
143         
144         <programlisting role="no-scilab-exec"><![CDATA[ 
145 X(i,j,k) = x(i)  
146 Y(i,j,k) = y(j)   for all (i,j,k) in [1,nx]x[1,ny]x[1,nz]
147 Z(i,j,k) = z(k)
148  ]]></programlisting>
149         
150         <para>
151             
152             一般的な場合, m 個の入力引数<literal>x1, x2, ..,
153                 
154                 xm
155                 
156             </literal>
157             
158             ,それから m個の出力引数
159             
160             <literal>X1, X2, .., Xm</literal> は以下のような
161             
162             大きさ <emphasis>nx1 x nx2 x ... x
163                 
164                 nxm
165                 
166             </emphasis>
167             
168             のハイパー行列となります :
169             
170         </para>
171         
172         <programlisting role="no-scilab-exec"><![CDATA[ 
173 Xj(i1,i2,...,ij,...,im) = xj(ij)   
174 for all (i1,i2,...,im) in [1,nx1]x[1,nx2]x...x[1,nxm]  
175  ]]></programlisting>
176         
177     </refsection>
178     
179     <refsection>
180         
181         <title>例</title>
182         
183         <programlisting role="example"><![CDATA[  
184 // 簡単な2次元グリッドを作
185 nx = 40; ny = 40;
186 x = linspace(-1,1,nx);
187 y = linspace(-1,1,ny);
188 [X,Y] = ndgrid(x,y);
189 // グリッド上で関数を計算してプロット
190 //deff("z=f(x,y)","z=128*x.^2 .*(1-x).^2 .*y.^2 .*(1-y).^2");
191 deff("z=f(x,y)","z=x.^2 + y.^3")
192 Z = f(X,Y);
193 clf()
194 plot3d(x,y,Z, flag=[2 6 4]); show_window()
195  ]]></programlisting>
196         
197         <scilab:image>
198             
199             nx = 40; ny = 40;
200             
201             x = linspace(-1,1,nx);
202             
203             y = linspace(-1,1,ny);
204             
205             [X,Y] = ndgrid(x,y);
206             
207             deff("z=f(x,y)","z=x.^2 + y.^3")
208             
209             Z = f(X,Y);
210             
211             plot3d(x,y,Z, flag=[2 6 4]);
212             
213         </scilab:image>
214         
215         <programlisting role="example"><![CDATA[
216 // 簡単な3次元グリッドを作成
217 nx = 10; ny = 6; nz = 4;
218 x = linspace(0,2,nx);
219 y = linspace(0,1,ny);
220 z = linspace(0,0.5,nz);
221 [X,Y,Z] = ndgrid(x,y,z);
222 // 3次元グリッドを表示する ...
223 XF=[]; YF=[]; ZF=[];
224 for k=1:nz
225    [xf,yf,zf] = nf3d(X(:,:,k),Y(:,:,k),Z(:,:,k));
226    XF = [XF xf]; YF = [YF yf]; ZF = [ZF zf];
227 end
228 for j=1:ny
229    [xf,yf,zf] = nf3d(matrix(X(:,j,:),[nx,nz]),...
230                      matrix(Y(:,j,:),[nx,nz]),...
231                      matrix(Z(:,j,:),[nx,nz]));
232    XF = [XF xf]; YF = [YF yf]; ZF = [ZF zf];
233 end
234 clf()
235 plot3d(XF,YF,ZF, flag=[0 6 3], leg="X@Y@Z")
236 xtitle("A 3d grid !"); show_window()
237  ]]></programlisting>
238         
239         <scilab:image>
240             
241             nx = 10; ny = 6; nz = 4;
242             
243             x = linspace(0,2,nx);
244             
245             y = linspace(0,1,ny);
246             
247             z = linspace(0,0.5,nz);
248             
249             [X,Y,Z] = ndgrid(x,y,z);
250             
251             
252             
253             XF=[]; YF=[]; ZF=[];
254             
255             
256             
257             for k=1:nz
258             
259             [xf,yf,zf] = nf3d(X(:,:,k),Y(:,:,k),Z(:,:,k));
260             
261             XF = [XF xf]; YF = [YF yf]; ZF = [ZF zf];
262             
263             end
264             
265             
266             
267             for j=1:ny
268             
269             [xf,yf,zf] = nf3d(matrix(X(:,j,:),[nx,nz]),...
270             
271             matrix(Y(:,j,:),[nx,nz]),...
272             
273             matrix(Z(:,j,:),[nx,nz]));
274             
275             XF = [XF xf]; YF = [YF yf]; ZF = [ZF zf];
276             
277             end
278             
279             plot3d(XF,YF,ZF, flag=[0 6 3], leg="X@Y@Z")
280             
281             xtitle("A 3d grid !"); 
282             
283         </scilab:image>
284         
285     </refsection>
286     
287     <refsection role="see also">
288         
289         <title>参照</title>
290         
291         <simplelist type="inline">
292             
293             <member>
294                 
295                 <link linkend="kron">kron</link>
296                 
297             </member>
298             
299         </simplelist>
300         
301     </refsection>
302     
303 </refentry>
304