方法一
http://www.youtube.com/watch?v=9Fuc6T4_74M
fid = fopen('input.txt', 'r');
data = fread(fid);
CharData = char(data);
fclose(fid);
input = CharData;
e.g
input =
b
a
t
!
!
c
a
t
c
a
t
方法二
fidin = fopen('input.txt'); % open input.txt
fidout = fopen('data.txt','w'); % create data.txt
while ~feof(fidin) % end of file?
tline = fgetl(fidin); % read lines
fprintf(fidout,'%s\n\n',tline); % wirte to file.txt
end
fclose(fidout);
input = importdata('data.txt'); % import data.txt into workspace: variable = input
input = cell2mat(input);