Given a string that represents the name of a person, how do I get the first two characters of this string as a new variable?
Is there a function in MATLAB that can do this, or do I need to program it in a MATLAB code file?
Jack --> Ja
Cleve --> Cl
Given a string that represents the name of a person, how do I get the first two characters of this string as a new variable?
Is there a function in MATLAB that can do this, or do I need to program it in a MATLAB code file?
Jack --> Ja
Cleve --> Cl
Strings are treated as arrays in matlab so you can use normal array notation.
personName = 'something';
firstTwoLetters = personName(1:2);