MATLAB: How to store the content of arrays as observations in different variables

char array

After OCR text extraction, the output looks like this:
ans=
'MOUNTAIN
bird
'
ans=
'LAKE
fish
'
I would like to convert these char arrays into a variable "places" with all the words in upper cases as observations and the variable "animals" with all the words in lower cases as observations. Thanks in advance for your help!

Best Answer

Hi Federica,
Assuming that the output of the OCR text extraction always contains the name of a place in uppercase followed by the name of an animal in lowercase, the function isstrprop can then be used to determine the indexes of the uppercase and lowercase letters. This can then be used to create the variables places and animals as shown below:
data = 'MOUNTAIN bird';
idxplace = isstrprop(data,'upper');
idxanimal = isstrprop(data,'lower');
places = data(idxplace);
animals = data(idxanimal);