필터 지우기
필터 지우기

How to split vector to seqences

조회 수: 1 (최근 30일)
Milos Kopec
Milos Kopec 2018년 12월 3일
답변: Milos Kopec 2018년 12월 3일
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일
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 2018년 12월 3일
reshape(x,3,[])
reshape(x,[],3)
  댓글 수: 1
Milos Kopec
Milos Kopec 2018년 12월 3일
thank you,I try use this

댓글을 달려면 로그인하십시오.


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

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by