function M = read_mat_from_binary(fname)
fp = fopen(fname,'r');
m = fread(fp,1,'int32');
n = fread(fp,1,'int32');
 
M = zeros(m,n);
for j=1:n
    for i=1:m
 		M(i,j) = fread(fp,1,'double');
    end
end
fclose(fp);

end
