alternate way , without ismember function

6 ビュー (過去 30 日間)
Life is Wonderful
Life is Wonderful 2020 年 10 月 8 日
コメント済み: Star Strider 2020 年 10 月 8 日
Hi
I am having problems in using the ismember function, so I want to replace ismember and I need help in replacing the function.
Below is example code
INData = [
0.0120849609375
0.014190673828125
0.015838623046875
0.01214599609375
0.012481689453125
0.0123291015625
0.621002197265625
0.017181396484375
0.015167236328125
0.015350341796875
0.014556884765625
0.01739501953125
0.621002197265625
0.023162841796875
0.017578125
0.01361083984375
0.01239013671875
0.012115478515625
0.012451171875
0.01702880859375
0.01214599609375
0.012725830078125
0.0125732421875
0.012603759765625
0.012359619140625
0.014190673828125
0.013214111328125
0.013427734375
0.01531982421875
0.621002197265625
0.01239013671875
0.013092041015625
0.017791748046875
0.015960693359375
];
dMark = [7 13 30];
s_data = ismember(1:size(INData(:,1),1),dMark);
s_data =
1×34 logical array
0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
I need help in replacing isemember function.
Thank you

採用された回答

Star Strider
Star Strider 2020 年 10 月 8 日
The ismember function is doing exactly what you told it to do! What’s the problem?
  20 件のコメント
Life is Wonderful
Life is Wonderful 2020 年 10 月 8 日
Thanks a lot for all the efforts and help. I am greatful for your explantion as well.
Star Strider
Star Strider 2020 年 10 月 8 日
As always, my pleasure!
This was an interesting problem!

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

その他の回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 10 月 8 日
An alternative approach
dMark = [7 13 30];
s_data = false(1, size(INData, 1));
s_data(dMark) = 1;
  3 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 10 月 8 日
Don't check the output of s_data(dMark). Just run
s_data
after running my code.
Life is Wonderful
Life is Wonderful 2020 年 10 月 8 日
Your interpretation is right s_data give right output!

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

カテゴリ

Help Center および File ExchangeInput Specification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by