mustBeNonzeroLengthText(value) throws an error
if value does not have at least one character in each element or if the
input is not text. This function does not return a value.
Create an empty string named txt. Call
mustBeNonzeroLengthText with txt as an input.
mustBeNonzeroLengthText throws an error since the variable is a piece
of text with zero length.
txt = "";
mustBeNonzeroLengthText(txt)
Value must be text with one or more characters.
Use mustBeNonzeroLengthText to restrict the input
argument values that are accepted by a function. You can accomplish this by adding an
arguments block to the function that validates the input arguments
This function restricts the value of the argument
nonzeroLengthText to nonzero length text values.
function MyFunction(nonzeroLengthText)
arguments
nonzeroLengthText {mustBeNonzeroLengthText}endend
Call the function. MATLAB® calls mustBeNonzeroLengthText on the value being
assigned to the argument. mustBeNonzeroLengthText issues an error
because the value "" is not text with one or more characters.
MyFunction("")
Error using MyFunction (line 3)
MyFunction("")
^^
Invalid argument at position 1. Value must be text with one or more characters.
Value to validate, specified as a scalar or array. If value is
not a string array, character array, or cell array of character vectors with at least
one character in each element, nonzeroLengthText will throw an
error.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.