How to Shorten This Logical Expression?

3 次查看(过去 30 天)
What is the best way to rewrite A in the shortest way?
B = 1:14;
A = B == 1 | B == 2 | B == 3 | B == 7 ;

采纳的回答

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

更多回答(1 个)

Image Analyst
Image Analyst 2016-8-14
How about
A = B <= 3 | B == 7 ;

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by