"All elements of matrix lower than x" translated into code?

1 次查看(过去 30 天)
Hello,
As indicated by the title, I want to translate to code a condition that occurs if all values of a matrix are below a certain value x.
I am trying this approach, but I don't think it works. Is there an equally simple way of writing this? Thanks in advance!
A = [alpha beta];
x = 100;
if A<x
d=1;
end

采纳的回答

Cris LaPierre
Cris LaPierre 2021-10-26
编辑:Cris LaPierre 2021-10-26
See Ch 12 of MATLAB Onramp (logical arrays). You may also be interested in the all function.
if all(A<x)
...
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by