필터 지우기
필터 지우기

Erron in reshaping a matrix

조회 수: 2 (최근 30일)
Ayda
Ayda 2011년 10월 9일
Good morning\evening
I had an error when i reshape a matrix
when i try to reshape this matrix from (6*5) into (1*30)
C =
0 0 0 0 0 0
0 0 0 1 1 1
0 0 1 1 1 1
0 0 1 1 1 1
0 0 1 1 1 1
the result was ans =
Columns 1 through 16
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0
Columns 17 through 30
1 1 1 1 0 1 1 1 1 0 1 1 1 1
As you can see that the original matrix has sex zeros form the first row then followed by three zeros from the second row then three ones
But the reshaped marix has 12 zereos insted of 9 zeros
it also has other error if you see that the origenal matrix have 2 zeros in the third raw , but after reshaping it return 1 zero. The same error happen for row 4.

채택된 답변

Titus Edelhofer
Titus Edelhofer 2011년 10월 9일
Hi,
the matrix is indexed columnwise. If you want to have it rowwise indexed you need to transpose:
reshape(C', 1, 30)
Titus

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by