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 commentaire

Roberto De
Roberto De le 18 Juil 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.

Connectez-vous pour commenter.

 Réponse acceptée

Guillaume
Guillaume le 18 Juil 2018

0 votes

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

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Produits

Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by