function y=H(x,a) % function Y=H(x,a) % Heavyside function returns % Y=1 for x > a % Y=1/2 for x=a % Y=0 for x < a % % this is equivalent to the H(x+a) % INPUTS: x = the x-axis at which values % need to be returned. % a = constant % NOTE: H(x-a), you need to y=H(x,-a) % % EXAMPLES % x=-10:0.2:10; a=3; % y=H(x,a); % plot(x,y); set(gca,'ylim',[-2 2]); y=zeros(length(x),1); in=find(x > -a); if ~isempty(in), y(in)=1; end; in=find(x== -a); if ~isempty(in), y(in)=1/2;end; in=find(x < -a); if ~isempty(in), y(in)=0; end;