IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
protect_against_inf.m
Go to the documentation of this file.
1 %> @ingroup misc maths graphicsapi
2 %> @file
3 %> @brief Replaces infinite values by maximum/minimum
4 %
5 %> @param y Vector
6 %> @return y With +Inf/-Inf values replaced by maximum/minimum respectively
7 function y = protect_against_inf(y)
8 bo = y ~= Inf & y ~= -Inf;
9 if sum(bo) == 0
10  y(1:end) = 0;
11 else
12  y(y == Inf) = max(y(bo));
13  y(y == -Inf) = min(y(bo));
14 end;
function protect_against_inf(in y)