필터 지우기
필터 지우기

i am working on a serial data and need to convert it from serial to parallel data.i have a matrix of 7500 x 1, and i need to divide it into 10 individual matrices of 750 x 1.

조회 수: 1 (최근 30일)
i can use reshape and vec2mat.but it convert it into one matrix of 750 x 10
  댓글 수: 2
Andrei Bobrov
Andrei Bobrov 2017년 9월 2일
and well,
A - your array [7500 x 1], M = reshape(A,[],10), then first your "individual matrix" = M(:,1) and etc.
zafran khan
zafran khan 2017년 9월 2일
i have already done it through this method.but i am looking for some for loops or any other smart way to do this

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

채택된 답변

Stephen23
Stephen23 2017년 9월 2일
편집: Stephen23 2017년 9월 2일
It is simple to split a matrix into matrices in a cell array using mat2cell, e.g.:
C = mat2cell(V,750*ones(10,1),1)
or using num2cell:
C = num2cell(reshape(V,[],10),1)
Do NOT try to automatically create matrices in the workspace: read this to know why:
  댓글 수: 3
Stephen23
Stephen23 2017년 9월 2일
편집: Stephen23 2017년 9월 2일
"but this does not suffice my question."
Really? Why not?
"i need to plit a 7500 x1 matix into 10 small matrix of 750 x 1."
Yes, that is what my code does.
"elements of splitted matrix should be of the same as in the parent matrix"
Yes, that is what my code does.
Did you even try it?
Lets have look:
>> V = rand(7500,1);
>> C = num2cell(reshape(V,[],10),1);
>> size(C) % show the number of output matrices = 10
ans =
1 10
>> size(C{1}) % show the size of the first output vector
ans =
750 1
Or if you want to see the size of every vector in C:
>> cell2mat(cellfun(@size,C(:),'uni',0))
ans =
750 1
750 1
750 1
750 1
750 1
750 1
750 1
750 1
750 1
750 1
So my code created ten 750x1 output vectors, just as you requested. Now lets have a look at the elements of the first vector:
>> V(1:8) % e.g. the first 8 elements of the original data
ans =
0.81472
0.90579
0.12699
0.91338
0.63236
0.09754
0.2785
0.54688
>> C{1}(1:8) % the first 8 elements of the first output vector
ans =
0.81472
0.90579
0.12699
0.91338
0.63236
0.09754
0.2785
0.54688
>>
Note that the elements are exactly the same, exactly as you require.
So there it is: my answer split your 7500x1 vector into ten vectors of size 750x1, with exactly the same elements as the original data vector. I have no idea why you think it does not work: can you please explain why you think it does not work?
Image Analyst
Image Analyst 2017년 9월 2일
In an above comment, he said "i am looking for some for loops" so I'm guessing that a for loop is what was specified in a homework problem - he just didn't tag it as homework.

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

추가 답변 (0개)

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by