index=linspace(0,2*pi,768);
fid=fopen('路径\cosin.mif','W' );
fprintf(fid,'WIDTH=8;\n');
fprintf(fid,'DEPTH=768;\n\n');
fprintf(fid,'ADDRESS_RADIX=UNS;\n');
fprintf(fid,'DATA_RADIX=UNS;\n\n');
fprintf(fid,'CONTENT BEGIN\n\n');
for x=1:768;%因为fprintf 要为整数所以一定要从1开始
i=x-1;
y=round(100*(sin(index)+1));
fprintf(fid,'%d',i);
fprintf(fid,':');
fprintf(fid,'%d\r',y(x));
fprintf(fid,';\n');
end
fprintf(fid,'END;'); % the end of the file %
fclose(fid);
plot(index,y);
grid on |