How to split vector to seqences

1 vue (au cours des 30 derniers jours)
Milos Kopec
Milos Kopec le 3 Déc 2018
Hello, can u help me please? I want to split generated numbers to 3 sequences for 8 bits ,for example i used :
x = randi([0 1],24,1)
and now i want to split these 24 numbers to 3 sequences for 8 bits, I could not find the answer.

Réponses (3)

ahmed nebli
ahmed nebli le 3 Déc 2018
Modifié(e) : ahmed nebli le 3 Déc 2018
u can use something like that:
for i=1:8:24
var = x[i,1]; % here you need to do what store var in someplace else in order not to loose it
end
  1 commentaire
Milos Kopec
Milos Kopec le 3 Déc 2018
thank you

Connectez-vous pour commenter.


Fangjun Jiang
Fangjun Jiang le 3 Déc 2018
reshape(x,3,[])
reshape(x,[],3)
  1 commentaire
Milos Kopec
Milos Kopec le 3 Déc 2018
thank you,I try use this

Connectez-vous pour commenter.


Milos Kopec
Milos Kopec le 3 Déc 2018
Guys I thinking about it, can you help me yet ? Idk if I do it right. so I have to task , witch consits of 3 parts:
  1. generate random bit sequence 0,1 .... I did this
  2. split generated numbers to 3 sequences for 8 bits ... you helped me with this
  3. replace bit positions within the sequence I create myself ... I have no idea how to do it , I used mathworks,google, but I still could not find the answer. I do not understand that.
Can you help me please ?
my code looks like this :
clear all;
x = randi([0 1],24,1) %generate 0,1
reshape(x,[8,3]) % splited 3,8
In command window it looks like this :
x =
1
1
0
1
0
0
1
1
1
0
1
0
1
1
1
0
0
0
1
1
1
1
1
0
ans =
1 1 0
1 0 0
0 1 1
1 0 1
0 1 1
0 1 1
1 1 1
1 0 0 20181203_224007.jpg

Catégories

En savoir plus sur Timing and presenting 2D and 3D stimuli dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by