2017-07-08 174 views
0

我正在尝试制作一个阿拉伯字母数组,并在其上写入文本文件中的字母。问题是matlab无法识别它,它给'?'而不是字母。我正在使用matlab 2016a。将阿拉伯字母存储到字符数组matlab

% slCharacterEncoding() 
fid = fopen('nv.txt', 'w+', 'n', 'UTF-8'); 
words = ['ا','ل','ل','ه',' ', 'و']; 
for i=1:length(words) 
    w=words(1,i); 
    fprintf(fid,'%s',w); 
end 
fclose(fid); 

enter image description here

奇怪的是,当我从命令进入words阵列和评论这是从代码行的作品。 enter image description here

回答

2

一种解决方法是使用uint16获得在命令窗口中的16位整数值即

>> words = ['ا','ل','ل','ه',' ', 'و']; 
>> uint16(words) 

ans = 

    1575 1604 1604 1607  32 1608 

现在您的m文件替换words = char([1575 1604 1604 1607 32 1608]);

+0

与我发布的相同,2分钟差异:D。我会删除我的。 – Misaki