How can I store the content of arrays as observations in different variables?

1 view (last 30 days)
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!

Accepted Answer

Sujay C Sharma
Sujay C Sharma on 4 Jun 2020
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);

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!