Reading greek letters!
9 views (last 30 days)
Show older comments
I need to read text from an EXCEL file that will include greek letters in some cells. While I can transform the letters (e.g., spelling out "alpha" in place of the actual letter), I need to preserve the content. Currently, when I read the file using readcell, I get the greek letters in the text, but as soon as I try to do anything with them they get substituted with question marks. This is problematic, as I need to make decisions based on the text, and can't do that if every theta, eta, and nu is just going to become identical ?'s.
So, any ideas?
EDIT: For clarification on "...but as soon as I try to do anything..."
Below, the word tau, by itself, is the greek letter itself
%%%%%%%%%%%%%%%%%%%%%%
>>Text = readcell(File,'Sheet',Sheet);
>>VN = char(Text(2,1));
VN =
tau
>>switch VN
case tau
A = 'tau';
otherwise
A = 'ERROR';
end
>>A
A =
'ERROR';
%%%%%%%%%%%%%%%%%%%%%%%
Please note that when I call VN, I see the letter tau on the screen. When I save it in an .mat file and reopen, VN = '?'.
In essense, I need a way to do the reverse of what char(945) would do - where char(945) takes a MATLAB-manipulatable value and produces a greek letter, I need something that will take a greek letter and produce a MATLAB manipulative value (like Unicode or '\alpha').
5 Comments
Adam Danz
on 20 Nov 2019
@Stephen Hall, I'll copy an improved version of my comment to the answers section so your question appears as answered.
Accepted Answer
Adam Danz
on 20 Nov 2019
[continued from comment section under the answer]
If you're just referencing single greek letters, you could use the double() value for those characters.
For example, the double() value for tau is
value = double('τ') % 964, lower case
value = double(upper('τ')) % 932, upper case
So when you read in the letters, you can instantly convert them to their numeric values.
VN = double(Text{2,1});
and then in your switch statement,
switch VN
case [932, 964] % for upper and lower cases
% code
otherwise
error()
end
0 Comments
More Answers (0)
See Also
Categories
Find more on Labels and Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!