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 Kommentar

Roberto De
Roberto De am 18 Jul. 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.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Guillaume
Guillaume am 18 Jul. 2018

0 Stimmen

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

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by