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

2 Ansichten (letzte 30 Tage)
Elia Paini
Elia Paini am 19 Mär. 2022
Bearbeitet: Stephen23 am 15 Dez. 2022
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!

Antworten (1)

Torsten
Torsten am 19 Mär. 2022
g = @(x) (x > 0).*f(x)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by