You have
string st = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
In MATLAB, that is equivalent to calling
string('st', '=', "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
This will get you the error,
No constructor 'string' with matching signature found.
MATLAB does not put the variable type before the variable name when an assignment is made. Leave out the variable type: just use
st = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
You have
st.Length
However, there is no Length method for MATLAB string objects. MATLAB string objects are arrays of strings, so if you want the length of one element of the array you need to extract out that one element and ask for its length:
length(st{1})
In the case of a string array, if you wanted to find the length of every element, you could use
cellfun(@length, st)
but if you do that, watch out that you might be wanting a different random position for each string in the string array.
You have
Random.Range(st.Length)
MATLAB does not have any package named "Random" with a static method named "Range". You kind of look like you are using Java, but Java does not have that either. https://www.mkyong.com/java/java-generate-random-integers-in-a-range/ . Consider using randi()
You have
a = st[Random.Range(st.Length)];
In MATLAB, [] is only for building lists and arrays, and is not used for indexing. Also, because string objects are arrays, if you try to just index, you would be indexing which string rather than indexing into a string.
You have two choices:
1)
pos = ... the random location you determined from above
a = extractBetween(st, pos, pos);
This will extract the given position from each string in the string array, giving back a string array. Or,
2)
st{1}(pos)
this will extract the given position from the first string in the string array.
You have
charCell = {a1, a2; a3, a4};
However, you have not defined a1, a2, a3, or a4.
You have
switch vowles(letter)
However, you have not defined "vowles" or "letter". Does "vowles" have anything to do with "vowels" ?
.... I would suggest that you read https://www.mathworks.com/matlabcentral/answers/360652-display-the-characters-as-output