Greek character in script turned to a square or a question mark - any ideas why?

24 ビュー (過去 30 日間)
Nick Aggelopoulos
Nick Aggelopoulos 2020 年 8 月 3 日
編集済み: Walter Roberson 2020 年 8 月 10 日
I copied a script from an older computer with Matlab 2012b to a new computer with Matlab 2017a and when I opened it, a Greek character 'μ' was encoded as a little square (maybe missing font). After Installing the Greek language option in MS Windows and typing in its place the letter μ, running the script reported an error (wrong matrix dimensions). So I reloaded the saved script and the character μ had now been replaced by a questionmark. Does anyone know what is going on? I have not witnessed this before. The faulty character encoding may have nothing to do with Matlab itself.

回答 (3 件)

maiaL 2020 年 8 月 3 日
You can refer to this if you want to print greek and other special characters. But I don't think you can have these characters within the code itself.

Nick Aggelopoulos
Nick Aggelopoulos 2020 年 8 月 4 日
編集済み: Nick Aggelopoulos 2020 年 8 月 4 日
The line is
while infoHeadr (pe) ~='μ'
The matlab script was running fine on other computers. On this new computer, the μ was instead displayed as a little square before I installed the Greek keyboard. After that it was displayed as a μ
Matlab reported an error (Index exceeds matrix dimensions) when reaching this line:
On re-opening the saved file, the line instead of a μ has a questionmark
while infoHeadr (pe) ~='?'
The matrix dimension error of course is reported whether there is a little square or a questionmark and there rather seems something amiss about the character encoding. It is likely the error has something to do with encoding or something else unrelated to matlab, although the result is that it prevents the matlab script from being executed. On the other computers, the μ is never replaced automatically by those other things.

Walter Roberson
Walter Roberson 2020 年 8 月 4 日
編集済み: Walter Roberson 2020 年 8 月 4 日
R2020a is the first release that handles UTF8 encoding in a way that is natural to the user.
In releases before that, you had to use hacks and obscure calls to tell MATLAB that you were going to use non-ASCII. And on your new computer, you have not used those obscure settings.
My recommendation would be to upgrade to R2020a.
  4 件のコメント
Nick Aggelopoulos
Nick Aggelopoulos 2020 年 8 月 10 日
編集済み: Walter Roberson 2020 年 8 月 10 日
Thanks again for your help. Just in case it is of help to others, the following edit in lcdata.xml, a file found in MATLAB/bin root directory, solved my problem (I also had to delete an old cached file called by the program when searching for the header info):
<?xml version="1.0" encoding="UTF-8" ?>
<!-- MathWorks Locale Database -->
<!-- File Name: lcdata.xml -->
<!-- Copyright 2007-2016 The MathWorks, Inc. -->
<lcdata xmlns:xsi="" xsi:noNamespaceSchemaLocation="lcdata.xsd">
<!-- Note: -->
<!-- This locale database is used to customize the MathWorks locale database. -->
<!-- Codeset entry example -->
<!-- <codeset> -->
<!-- <encoding name="StandardEncodingName" jvm_encoding="JavaEncodingName"> -->
<!-- <encoding_alias name="AliasName"/> -->
<!-- </encoding> -->
<!-- </codeset> -->
<!-- Locale entries example -->
<!-- <locale name="StandardLocaleName" encoding="EncodingName" xpg_name="XpgLocaleName"> -->
<!-- <alias name="AliasName"/> -->
<!-- "region_alias" is only for Mac -->
<!-- <region_alias name="RegionAliasName"/> -->
<!-- </locale> -->
<encoding name="UTF-8">
<encoding_alias name="US-ASCII" />



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!

Translated by