mustBeText
説明
例
入力がテキストであることを検証
数値の配列 notText
を作成してから、mustBeText
を使用して値を検証します。配列にテキストが含まれていないため、mustBeText
はエラーをスローします。
notText = [1 2 3]; mustBeText(notText)
Value must be a character vector, string array, or cell array of character vectors.
引数値の制限
mustBeText
を使用して、関数によって受け入れられる入力引数値を制限します。これを行うには、入力引数を検証する関数に引数ブロックを追加します。
この関数により、引数 textInput
の値がテキスト値に制限されます。
function MyFunction(textInput) arguments textInput {mustBeText} end end
数値の入力引数を指定して、関数を呼び出します。MATLAB® は、引数に割り当てられている値に対して mustBeText
を呼び出します。値 2
はテキストでないため、mustBeText
はエラーを発行します。
MyFunction(2)
Error using MyFunction MyFunction(2) ↑ Invalid argument at position 1. Value must be a character vector, string array, or cell array of character vectors.
入力引数
value
— 検証する値
スカラー | 配列
検証する値。スカラーまたは配列として指定します。value
が string スカラーまたは配列、文字配列、または文字ベクトルの cell 配列でない場合、mustBeText
はエラーをスローします。
例: mustBeText('foo')
拡張機能
C/C++ コード生成
MATLAB® Coder™ を使用して C および C++ コードを生成します。
バージョン履歴
R2020b で導入
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)