complex
複素数を計算する
呼び出し手順
c = complex(u) c = complex(a, b)
引数
- u, a, b
- scalars, vectors, matrices or hypermatrices of real numbers.
If both
a
andb
are not scalars, they must have the same sizes. - c
- array of complex numbers, of the size of
u
or ofa
andb
. Ifu
is sparse, or ifa
andb
have the same sizes and both are sparse, thenc
is also sparse. Otherwisec
is dense-encoded.
説明
c = complex(u) は, u
を実部,
0 を虚部とする複素数を作成します.
c = complex(a,b) は実部a
,
虚部b
の複素数を作成します.
This function is equivalent to a + imult(b)
, which
handles properly special Inf and NaN real and imaginary parts.
例
以下の例では,実部と虚部から複素数を生成します.
complex(1,2) complex([1 2],[3 4])
a
のみが指定された場合, 虚部は0に設定されます.
complex([1 2 3])
a
がスカラーで b
が
行列の場合, 結果 c
は,
b
と同じ大きさとなります.
同様に, b
がスカラーで a
が行列の場合, 結果 c
は
a
と同じ大きさになります.
c = complex([1 2 3], 4) c = complex(1, [2 3 4])
a
と b
が
異なる大きさの行列の場合,以下のセッションのような
エラーが発生します.
-->complex(ones(2,3),ones(4,5)) !--error 10000 complex: Incompatible input arguments #1 and #2: Same sizes expected. at line 33 of function complex called by : complex(ones(2,3),ones(4,5))
With special real or/and imaginary parts:
r = [0 0 0 %inf %inf %inf %nan %nan %nan].'; i = [0 %inf %nan 0 %inf %nan 0 %inf %nan].'; [r, i] // Then let's compare complex(r, i) with r + i*%i : [complex(r,i), r+i*%i]
--> [r, i] ans = 0. 0. 0. Inf 0. Nan Inf 0. Inf Inf Inf Nan Nan 0. Nan Inf Nan Nan // Then let's compare complex(r, i) with r + i*%i : --> [complex(r,i), r+i*%i] ans = 0. + 0.i 0. + 0.i 0. + Infi Nan + Infi 0. + Nani Nan + Nani Inf + 0.i Inf + 0.i Inf + Infi Nan + Infi Inf + Nani Nan + Nani Nan + 0.i Nan + 0.i Nan + Infi Nan + Infi Nan + Nani Nan + Nani
履歴
バージョン | 記述 |
6.1.1 | Extension to sparse arrays. |
Report an issue | ||
<< Complex | Complex | conj >> |