intProj

Projects each value of a vector or matrix inside a interval.

Contents

Syntax

res = intProj(a,b,t)

Description

res = intProj(a,b,t) projects each value of a vector or matrix t into the interval $[a,b]$.

Example

Code

t = [-3.1, -2, 1.5, 5];
res = intProj(-2,4,t);
A = [t; res]

Result

A =
-3.1000   -2.0000    1.5000    5.0000
-2.0000   -2.0000    1.5000    4.0000

Input Arguments

Output Arguments

More About

This function is used in pda.m.

See Also

function res = intProj(a,b,t) % intervall projection
%SS_{a,b}(t) = a if t_i \leq a; t_i if t_i \in (a,b); b if t_i \geq b
%res = @(a,b,t) a.*(t<=a) + t.*and(a<t,t<b) + b.*(b<=t);
res = a.*(t<=a) + t.*and(a<t,t<b) + b.*(b<=t);
%SSabAlternative = @(t) t./max(1,abs(t)); % only if a = b = 1
end