Q:

store Arabic letters into character array matlab

I am trying to make an array of Arabic letters, loop on it and write the letters in text file. The problem is matlab can't recognize it, it gives '?' instead of the letters. I am using matlab 2016a.
% 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);

The weird thing is that it works when i enter the words array from the command and comment it's line from the code.

A:

One workaround would be to use uint16 to get their 16-bit integer value in the command window i.e.
>> words = ['ا','ل','ل','ه',' ', 'و'];
>> uint16(words)

ans =

   1575   1604   1604   1607     32   1608

Now substitute words = char([1575 1604 1604 1607 32 1608]); in your m-file.

