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
를 사용하여 함수가 받는 입력 인수 값을 제한합니다. 입력 인수의 유효성을 검사하는 함수에 arguments 블록을 추가하여 이를 수행할 수 있습니다.
이 함수는 인수 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형 스칼라 또는 배열, 문자형 배열, 또는 문자형 벡터로 구성된 셀형 배열이 아닌 경우 mustBeText
는 오류를 발생시킵니다.
예: mustBeText('foo')
확장 기능
C/C++ 코드 생성
MATLAB® Coder™를 사용하여 C 코드나 C++ 코드를 생성할 수 있습니다.
버전 내역
R2020b에 개발됨
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 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)