读取数字:
M = dlmread('1.csv');
存储数字:
dlmwrite('myFile.csv',M,'delimiter',',')
读取文本文件:
[cellA, cellB] = textread('1.csv', '%s%s', 'delimiter', ',');
for index = 1:length(cellA)
if ismember(cellA(index), str1)
%do something
str2 = char(cellA(index))
break
end
end
读取文本文件:
input = '1.csv';
fileID = fopen(input,'r');
C = textscan(fileID,'%d %d %d %d %f %f %f %d','HeaderLines',1,'Delimiter',',');
fclose(fileID);
C_list = C{1,5}
C_element = C_list(100)
按指定格式存储数字和文本文件:
output = '1.csv';
fileID = fopen(output,'a');
fprintf(fileID,'%s, %d\n',name,grade);
fclose(fileID);