MATLAB: Write and print to a file

filewriting

So I am trying to prin in the file created like this in example:
11100111
....
....
10100101
%%
t = 0:1:255
a = 127+127*sin(t)
rotunjit = round(a);
fid = fopen('vlsi2.txt','w');
binar=dec2bin(rotunjit)
for i=0:7
fwrite(fid,binar)
fprintf(fid,'\n')
end
fclose(fid);
This is my code.

Best Answer

t = 0:1:255
a = 127+127*sin(t);
rotunjit = round(a);
binar=dec2bin(rotunjit, 8);
fid = fopen('vlsi2.txt','w');
fprintf(fid, '%c%c%c%c%c%c%c%c\n', binar.'); %transpose is important
fclose(fid);