ドキュメンテーションヘルプ センター
最新のリリースでは、このページがまだ翻訳されていません。 このページの最新版は英語でご覧になれます。
配列が実数かどうかの判別
tf = isreal(A)
例
tf = isreal(A) は、数値配列 A に虚数部がない場合に logical 1 (true) を返し、それ以外の場合に logical 0 (false) を返します。
A
1
true
0
false
すべて折りたたむ
3 行 4 列の行列 A を定義します。
A = [7 3+4i 2 5i;... 2i 1+3i 12 345;... 52 108 78 3];
配列が実数かどうかを判別します。
tf = logical 0
A に複素数要素が含まれるため、isreal は false を返します。
isreal
関数 complex を使用して、ゼロ値の虚数部をもつスカラー A を作成します。
complex
A = complex(12)
A = 12.0000 + 0.0000i
A が実数かどうかを判別します。
A に虚数部があるため、虚数部の値が 0 であっても、実数ではありません。
A にゼロ値の虚数部をもつ要素があるかどうか判定します。
~any(imag(A))
ans = logical 1
A はゼロ値の虚数部をもつ要素を含んでいます。
2 つの複素数スカラー x と y を定義します。
x
y
x=3+4i; y=5-4i;
2 つの複素数スカラー x と y を加算すると実数になるかどうかを判定します。
A = x+y
A = 8
MATLAB® はゼロの虚数部を省略します。
isreal(A)
A は虚数部をもっていないので実数です。
cell 配列を作成します。
C{1,1} = pi; % double C{2,1} = 'John Doe'; % char array C{3,1} = 2 + 4i; % complex double C{4,1} = ispc; % logical C{5,1} = magic(3); % double array C{6,1} = complex(5,0) % complex double
C=6×1 cell array {[ 3.1416]} {'John Doe' } {[2.0000 + 4.0000i]} {[ 0]} {3x3 double } {[5.0000 + 0.0000i]}
C は 1 行 6 列の cell 配列です。
C
cell 配列の要素全体をループ処理して、実数要素と複素数要素を区別します。
for k = 1:6 x(k,1) = isreal(C{k,1}); end x
x = 6x1 logical array 1 1 0 1 1 0
C{3,1} と C{6,1} 以外はすべて実数配列です。
C{3,1}
C{6,1}
入力配列。スカラー、ベクトル、行列または多次元配列として指定します。
数値データ型の場合、A に虚数部がなければ、関数 isreal は true を返し、A に虚数部があれば関数 isreal は false を返します。
duration、calendarDuration、logical および char のデータ型の場合、isreal は常に true を返します。
duration
calendarDuration
logical
char
string、table、cell、struct、datetime、function_handle および object のデータ型の場合、isreal は常に false を返します。
string
table
cell
struct
datetime
function_handle
object
データ型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | string | struct | table | cell | datetime | duration | calendarDuration | function_handle 複素数のサポート: あり
single
double
int8
int16
int32
int64
uint8
uint16
uint32
uint64
配列 A の各要素が実数かどうかをチェックするには、A == real(A) を使用します。
A == real(A)
虚数部がすべてゼロであっても、isreal(complex(A)) は常に false を返します。
isreal(complex(A))
すべてゼロであっても、~isreal(x) は虚数部をもつ配列を検出します。
~isreal(x)
この関数は GPU 配列を完全にサポートしています。詳細については、GPU での MATLAB 関数の実行 (Parallel Computing Toolbox)を参照してください。
この関数は分散配列を完全にサポートしています。詳細については、分散配列を使用した MATLAB 関数の実行 (Parallel Computing Toolbox)を参照してください。
complex | isa | isfinite | isinf | isnan | isnumeric | isprime
isa
isfinite
isinf
isnan
isnumeric
isprime
この例の変更されたバージョンがシステム上にあります。代わりにこのバージョンを開きますか?
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office