How to Shorten This Logical Expression?

12 views (last 30 days)
What is the best way to rewrite A in the shortest way?
B = 1:14;
A = B == 1 | B == 2 | B == 3 | B == 7 ;

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 14 Aug 2016
A = ismember(B,[1 2 3 7])

More Answers (1)

Image Analyst
Image Analyst on 14 Aug 2016
How about
A = B <= 3 | B == 7 ;

Categories

Find more on Modeling in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!