Create in MATLAB

Find this useful? Support us: Star on GitHub 6
Category: String | Language: MATLAB

Sure, creating a string in MATLAB is simple. To create a string, enclose the characters of the string in either single quotes (' ') or double quotes (" "), like so:

myString1 = 'Hello World';
myString2 = "Hello MATLAB";

Both myString1 and myString2 are string variables containing the strings "Hello World" and "Hello MATLAB" respectively.

Here are a few more examples of creating strings in MATLAB:

% empty string
emptyString = '';

% string with newline character
newLineString = 'Hello\nWorld';

% string with double quotes
doubleQuotesString = "I said, ""Hello!""";

I hope this helps! Let me know if you have any more questions.