I need a function which returns 0 if the argument is negative

5 views (last 30 days)
Hi, I need a function in Matlab which returns 0 if the argument is negative:
f(x) = 0 if x < 0
f(x) = f(x) if x > 0
How can I do?
Thank you!

Answers (1)

Torsten
Torsten on 19 Mar 2022
g = @(x) (x > 0).*f(x)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!