view general/numerical/scalar/rectify.m @ 16:db7f4afd27c5

Rearranging numerical toolbox.
author samer
date Thu, 17 Jan 2013 13:20:44 +0000
parents general/numerical/rectify.m@e44f49929e56
children
line wrap: on
line source
function y=rectify(x)
% rectify - 'half wave' rectification, rectify(x) x>0 ? x : 0
%
% rectify :: [Size->real] -> [Size->nonneg].

y = (x>0) .* x;
% alternative implementation?
% i=(x<0); y=x; y(i)=0;