If statement - comparing single value to whole array

조회 수: 12 (최근 30일)
Jenniluyn Nguyen
Jenniluyn Nguyen 2020년 3월 12일
답변: Bhaskar R 2020년 3월 12일
Hello!
I'm currently trying to write an if statement that is something like this:
A = [6];
B = [1 6 4 2 4 8]
What 'if' statement can I make, that starts the conditional statement when any value within B is greater than A? I'm having trouble figuring out how to compare this single value to the entire array in B.
Thanks so much!

답변 (1개)

Bhaskar R
Bhaskar R 2020년 3월 12일
if any(B>A)
% your code
end

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by