Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

want to make a number of row matrix from a single row matrix

조회 수: 1 (최근 30일)
lafnath p
lafnath p 2016년 10월 25일
마감: MATLAB Answer Bot 2021년 8월 20일
i have a file with
line1:[1 2 3 4 5 6 7 8 9]
line2:[10 11 12 13 14 15 16 17 18] now i want to make a 3d matrix by
split line1 as[1 2 3],[4 5 6],[7,8,9]
and line2 as[10 11 12],[13,14 15],[16 17 18].
then i want to make 3 new matrixes as
mat1 =
[1 2 3;10 11 12]
mat2=
[ 4 5 6;13 14 15]
and
[7 8 9;16 17 18]

답변 (2개)

Andrei Bobrov
Andrei Bobrov 2016년 10월 25일
편집: Andrei Bobrov 2016년 10월 25일
Let A - your matrix (2 x 9)
A = reshape(1:18,[],2)';
out = reshape(A,2,3,[]);
  댓글 수: 2
lafnath p
lafnath p 2016년 10월 25일
reshaping each line will gives a single matrix in the specified dimension. but i want to make 3 row matrix from line1
Andrei Bobrov
Andrei Bobrov 2016년 10월 25일
you said: "then i want to make 3 new matrixes as
mat1 = [1 2 3;10 11 12]
mat2 = [ 4 5 6;13 14 15]
and [7 8 9;16 17 18]"

Thorsten
Thorsten 2016년 10월 25일
Your description is somewhat unclear to me. Do you mean
cat(3, reshape(line1, [3 3])', reshape(line2, [3 3])')

태그

Community Treasure Hunt

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

Start Hunting!

Translated by