Converting output from 'find' into a logical
11 次查看(过去 30 天)
显示 更早的评论
This is probably really trivial, but I can't seem to find the right command. I have the output from a find command (a 1700x1 double) with values like [9788;9790;9955...etc]
I want to create a logical 22879 entries long, with 'true' at the locations listed from the find command. i.e. the first entry in the logical will be at an index of 9788, the next at 9790 etc. All other entries in the logical should be '0'.
Help is much appreciated.
0 个评论
采纳的回答
James Tursa
2020-1-8
编辑:James Tursa
2020-1-8
E.g.,
x = the result of the find
y = false(22879,1);
y(x) = true;
But it may be better to create y with a direct logical expression instead of using the find( ) function. What does your expression using the find( ) function look like?
更多回答(1 个)
KSSV
2020-1-8
Read about ind2vec. By the way you can straightaway logical, there is no need to use find.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!