octave 06 and 08WIP

This commit is contained in:
Andrew 2019-12-17 00:29:33 +07:00
parent e9d7aa3900
commit c3777e550b
15 changed files with 303 additions and 0 deletions

21
1sem/octave/06/main.m Normal file
View file

@ -0,0 +1,21 @@
#stage 4
V=33;
rand("state", V);
#stage 5, 6, 7
fid = fopen("results.txt", "w+");
origs = -1000 + 2000*rand(1, 100);
abserrs = [];
for i = 1:100
x = origs(i);
binf = print_num_bin(x, 4);
decf = read_num_bin(binf);
abserr = abs(x - decf);
abserrs(end + 1) = abserr;
fprintf(fid, "%.6f %s %.6f %.6f\n", x, binf, decf, abserr);
end
fclose(fid);
#stage 8
stats = [min(abserrs), mean(abserrs), max(abserrs)];
save -ascii "stats.txt" stats;