MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   在Matlab中创建逆逻辑数组 (https://www.labfans.com/bbs/showthread.php?t=23905)

poster 2019-12-10 20:48

在Matlab中创建逆逻辑数组
 
我有一个逻辑数组isLand,如果索引在陆地上,则为true;如果索引不在陆地上(如海洋),则为false。如何轻松创建另一个逻辑数组isOcean,它与isLand相反。 isLand中的所有1将在isOcean中为零,反之亦然。

我知道我可以使用for循环来做到这一点,但我觉得有更好的方法。



[B]回答:[/B]

只需使用逻辑[URL="http://www.mathworks.com/help/techdoc/ref/logicaloperatorselementwise.html"]NOT[/URL]运算符:

isOcean = ~isLand; 轻松榨柠檬! ;)



[url=https://stackoverflow.com/questions/3711828]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 08:33

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.