matlab.unittest.constraints.IsReal クラス
名前空間: matlab.unittest.constraints
スーパークラス: matlab.unittest.constraints.BooleanConstraint
配列要素が実数値であるかどうかをテスト
説明
matlab.unittest.constraints.IsReal
クラスは、配列の要素が実数値であるかどうかをテストするための制約を提供します。
作成
説明
c = matlab.unittest.constraints.IsReal
は、配列のすべての要素が実数値であるかどうかをテストするための制約を作成します。この制約は、複素数ストレージを使用しない数値配列で満たされます。
例
配列要素が実数値であるかどうかをテスト
IsReal
制約を使用して、数値配列をテストします。
最初に、この例で使用するクラスをインポートします。
import matlab.unittest.TestCase import matlab.unittest.constraints.IsReal
対話型テスト用にテスト ケースを作成します。
testCase = TestCase.forInteractiveUse;
値 5
が実数であることを検証します。
testCase.verifyThat(5,IsReal)
Verification passed.
次に、値 complex(5)
をテストします。虚数部の値はゼロですが、値が複素数として格納されているため、テストは失敗します。
testCase.verifyThat(complex(5),IsReal)
Verification failed. --------------------- Framework Diagnostic: --------------------- IsReal failed. --> The value must be real. Actual Value: 5.000000000000000 + 0.000000000000000i
値 sqrt(-1)
をテストします。テストは失敗します。
testCase.verifyThat(sqrt(-1),IsReal)
Verification failed. --------------------- Framework Diagnostic: --------------------- IsReal failed. --> The value must be real. Actual Value: 0.000000000000000 + 1.000000000000000i
ベクトル [1 1 2 3 5 8 13]
が IsReal
制約を満たすかどうかをテストします。すべてのベクトル要素が実数であるため、テストはパスします。
testCase.verifyThat([1 1 2 3 5 8 13],IsReal)
Verification passed.
無限値と NaN
値を含むベクトルをテストします。テストはパスします。
testCase.verifyThat([-Inf 5 NaN],IsReal)
Verification passed.
行列 [1 NaN; -Inf 3i]
が実数でないことを検証します。
testCase.verifyThat([1 NaN; -Inf 3i],~IsReal)
Verification passed.
バージョン履歴
R2013a で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
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:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)