Convert time stamps to binary

3 次查看(过去 30 天)
Hi, I really don´t have any idea how to do this..... I have a vector
a=[0.6 0.7 1.1 2.1 2.2 ....]
I want to convert it to this
b=[0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 ......]
Sampling frequency in this example is 0.1. I am sure there is a really easy way to do this but I can´t think of anything useful.
Thanks for the help,
Roberto
  1 个评论
Roberto De
Roberto De 2018-7-18
Ok sorry, the 1s are indexed by a. For this reason 1 is in position 6,7,11,21 and 22 in vector b. I hope it is clearer now.

请先登录,再进行评论。

采纳的回答

Guillaume
Guillaume 2018-7-18
b = [];
b(round(a/0.1)) = 1
The round is necessary because of floating point precision.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by