I'm writting a code to convert integer to unary using the matlab
i read integers from file and write the unary in other file
the problem the file i write in is always empty (nothing is Written )
this is my attempt
the test.txt contain 1 2 3 4
file_read=fopen('d://test.txt');
file_write=fopen('d://write.txt','w');
line=fgets(file_read);
code2=[];
num=str2num(line);
len=length(num);
for (i=1:len)
number=num(i);
z=zeros(1,number-1)
code=[z 1]
end
fwrite(file_write,code)
fclose(file_write)