Converting output from 'find' into a logical

8 ビュー (過去 30 日間)
Jessica Hiscocks
Jessica Hiscocks 2020 年 1 月 8 日
コメント済み: Jessica Hiscocks 2020 年 1 月 9 日
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.

採用された回答

James Tursa
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 件のコメント
Jessica Hiscocks
Jessica Hiscocks 2020 年 1 月 9 日
Thank you, this is exactly what I needed!
This is actually the last step of a multi stage process.
  1. Start with wholeDataset
  2. Create a subset (onePhaseDataset) including only one phase (i.e.crystallographic geometry), and get output from the corresponding 'find' command (find1)
  3. Process the subset through a command (the mtex angle/orientation function) which will only work when the input is a single phase, to generate the finalDataset and also get the output of the corresponding find command (find2).
  4. Use compare1=find1(find2) such that the resulting index values are those referencing positions in the original wholeDataset, but including only those values that were part of finalDataset.
  5. Use your provided answer to generate a logical I can pass back to my application that will let me convert (in one operation) wholeDataset to finalDataset without having to call any of the other variables or functions involved in the calculations.

サインインしてコメントする。

その他の回答 (1 件)

KSSV
KSSV 2020 年 1 月 8 日
Read about ind2vec. By the way you can straightaway logical, there is no need to use find.
  1 件のコメント
Jessica Hiscocks
Jessica Hiscocks 2020 年 1 月 9 日
Unfortunately, I don't have the deep learning toolbox, so this approach is not an option. I actually can't use a logical instead, because one of the functions I'm using to filter the data will return an error when invalid data is passed to it. I'm using a two step process; first remove the data that will cause the error, then determine the final subset, then generate a logical that would do the process in one step.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by