Azzera filtri
Azzera filtri

How to split vector to seqences

1 visualizzazione (ultimi 30 giorni)
Milos Kopec
Milos Kopec il 3 Dic 2018
Risposto: Milos Kopec il 3 Dic 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.

Risposte (3)

ahmed nebli
ahmed nebli il 3 Dic 2018
Modificato: ahmed nebli il 3 Dic 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

Fangjun Jiang
Fangjun Jiang il 3 Dic 2018
reshape(x,3,[])
reshape(x,[],3)

Milos Kopec
Milos Kopec il 3 Dic 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

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by