入力を検証するか、エラーメッセージが表示された状態でプログラムを終了するには良い方法はありますか?Matlab - 入力検証
私はアサートを使っ0より大きい何か
if Length > 0 then
%%do code
else
%%Output error
%%nothing to do here so it just continues and exits
end
入力を検証するか、エラーメッセージが表示された状態でプログラムを終了するには良い方法はありますか?Matlab - 入力検証
私はアサートを使っ0より大きい何か
if Length > 0 then
%%do code
else
%%Output error
%%nothing to do here so it just continues and exits
end
Length = input('\nEnter a length in feet: ');
を取るたとえば
:
assert(Length>0,'Length is less than zero, exiting.')
は、あなたが、正規表現のためのMatlabの関数を使用して、入力文字列に、より高度なチェックを行うことができます
assert(Length > 0, 'your error msg')
あなたが機能assert
(タイプdoc assert
またはhelp assert
)に建てられたMatlabsを使用することができますhere
Input Parserは、本格的な関数入力 'バリデータ'としてMATLABによって提供されています。