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

5 次查看(过去 30 天)
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!

回答(1 个)

Torsten
Torsten 2022-3-19
g = @(x) (x > 0).*f(x)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by