I modified the write function for using the full range of values for each signals.
Before the physical max & min were the same for all signals and set to the highest and lowest values.
Now these values are determined for each signal, separately, and data is expanded or shrank to cover the full range of values.
Replace the lines 81-104 of lab_write_edf with :
% Scale and convert to in16 (data)
% Rounds max-min to the highest nearest int
% Works for most of the cases, but we should consider using scientific
% notation for very little values
maxV = ceil(max(data, , 2));
minV = floor(min(data, , 2));
% Physical max can't be equal to physical min
eqInd = find(maxV == minV);
maxV(eqInd) = maxV(eqInd) + 1;