reference:https://www.cnblogs.com/chensimin1990/p/9759368.html
t=0:2*pi/2^12:2*pi;
y=0.5*sin(t)+0.5;
r=ceil(y*(2^8-1));
%打开或者创建sin.coe文件
fid = fopen('sin.coe','w');
fprintf(fid,'MEMORY_INITIALIZATION_RADIX=10;\n');
fprintf(fid,'MEMORY_INITIALIZATION_VECTOR=\n');
%重复4096次,步长为1;
for i = 1:1:2^12
fprintf(fid,'%d',r(i));
if i==2^12
fprintf(fid,';');
else
fprintf(fid,',');
end
%每16个数据换行
if mod(i,15)==0
fprintf(fid,'\n');
end
end
fclose(fid); %关闭fid