%
% This file demonstrates how to read the weight vs. height data
% from a file 'weight.dat' and produce the matrix P
% considered in the file regression.m
%

%
% myfile - a small integer (the file descriptor) uniquely identifying 
% the connection to the file.
% msg - if there is an error, it will be set to an error message
%
[myfile, msg] = fopen("weight.dat", "r")


% val - the name to give to the read matrix
% count - the number of times the template was used 
%    (count should be same as number of columns in the result)
% [2, Inf] - the size specification; read into a matrix 2 x n, 
%    where n be as high as possible.
%
[val, count] = fscanf(myfile, "%f %f", [2, Inf]);

%
% Break the connection to the file
%
fclose(myfile)

% Now, we want the data in 2 columns, not 2 rows
P = val'
