%PENG 8.1
%Jeannette Spuhler for the exercise 2012/10/26

%binary
out_array = randn(1, 20);
[fid_binary, meddelande] = fopen('binaryreal', 'w');
count = fwrite(fid_binary,out_array, 'float64');
fclose(fid_binary);

[fid_binary, meddelande] = fopen('binaryreal', 'r');
[array, count] = fread(fid_binary, 20, 'float64');
test = sum(array-out_array');
status = fclose(fid_binary);

%formatted
out_array = randn(1, 20);
[fid_formatted, meddelande] = fopen('formattedreal', 'w');
count = fprintf(fid_formatted, '%f \t',out_array);
fclose(fid_formatted);

[fid_formatted, meddelande] = fopen('formattedreal', 'r');
[array, count] = fscanf(fid_formatted,'%f \t');
status = fclose(fid_formatted);
