Reading greek letters!

11 vues (au cours des 30 derniers jours)
Stephen Hall
Stephen Hall le 20 Nov 2019
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 commentaires
Stephen Hall
Stephen Hall le 20 Nov 2019
Adam, your comment is sufficient for an answer - I did not know that double would give the code for the letter. It does, and my problem is now resolved.
Thanks, both!
Adam Danz
Adam Danz le 20 Nov 2019
@Jeremy Hughes, thanks for the clarification; pedantry welcomed!
@Stephen Hall, I'll copy an improved version of my comment to the answers section so your question appears as answered.

Connectez-vous pour commenter.

Réponse acceptée

Adam Danz
Adam Danz le 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

Plus de réponses (0)

Catégories

En savoir plus sur Labels and Annotations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by