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

조회 수: 3 (최근 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에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by