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 Commento

Roberto De
Roberto De il 18 Lug 2018
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.

Accedi per commentare.

 Risposta accettata

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

Più risposte (0)

Categorie

Scopri di più su MATLAB in Centro assistenza e File Exchange

Prodotti

Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by