How to split vector to seqences

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.

回答(3 个)

ahmed nebli
ahmed nebli 2018-12-3
编辑:ahmed nebli 2018-12-3

0 个投票

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
Milos Kopec
Milos Kopec 2018-12-3

0 个投票

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

类别

帮助中心File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by