www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/SpecifyFileEncodingExample.m

    %% Determine Default File Encoding
%%
% This example shows how to determine the default encoding for your
% computer.
%%
% Open any text file without specifying the encoding. |patients.dat| is a sample text file that ships with
% MATLAB.

% Copyright 2015 The MathWorks, Inc.

fileID = fopen('patients.dat');
%%
% Call |fopen| again with |fileID| as the input. Request the fourth output
% argument.
[~,~,~,encodingOut] = fopen(fileID)
%%
% The |encodingOut| output argument is your computer's default encoding.
%%
% Close the text file.
fclose(fileID);