How do I do an if greater than or less than for a if statement

32 次查看(过去 30 天)
I need to do a question wehre it needs to be greater than or less than a certain limit.
This is specifically over g force so it needs to be greater tha -8g and less than 8g otherwise it displays a fail message

回答(1 个)

Jan
Jan 2022-5-8
编辑:Jan 2022-5-8
if f <= -8 || f >= 8
error('f is outside the valid range')
end
Alternative:
if abs(f) >= 8

类别

Help CenterFile Exchange 中查找有关 Mathematics and Optimization 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by