Clear Filters
Clear Filters

How to Shorten This Logical Expression?

3 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 Graph and Network Algorithms 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!