Your test code forgot to mention fid in the fprintf() so it did not output anything.
Remember that when you use fprintf() with the syntax fprintf(fid, A_String) that the values in A_String are treated as being the format specifier and so are subject to interpretation. The exception to this is if you are sending to a serial device or instrument, in which ase fprintf(fid, A_String) is equivalent to fprintf(fid, '%s\n', A_String) . If you want the exact string sent, you should use fwrite(fid, A_String) instead of fprintf(fid, A_String)
Anyhow, what you might be running into is that fopen() with so few parameters opens the file with the default character encoding for your system. You should fopen() with 4 parameters:
fid=fopen('test','w', 'n', 'ISO-8859-1')
(Note: the third parameter, 'n' in this example, cannot be skipped or left at '' or [] if you need to provide the encoding.)
Best Answer