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

1 次查看(过去 30 天)
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!

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by