How can I store the content of arrays as observations in different variables?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Federica Braccioli
am 3 Jun. 2020
Kommentiert: Federica Braccioli
am 8 Jun. 2020
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!
0 Kommentare
Akzeptierte Antwort
Sujay C Sharma
am 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);
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!