Why am I unable to use the RESHAPE function to convert a sparse vector to a three-dimensional matrix in MATLAB?

조회 수: 7 (최근 30일)
I create the following sparse vector:
A = sparse([1:24]);
Then I use the RESHAPE function to convert it to a 2-by-3-by-4 matrix:
B = reshape(A,2,3,4);
size(B)
However when I check the size of the result matrix, it is not what I am expecting:
ans =
2 12

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
MATLAB only supports two-dimensional sparse matrices. Therefore, when given a sparse matrix, the RESHAPE function returns a matrix, the second dimension of which has a length that is the product of all specified dimensions higher than the first.

추가 답변 (0개)

카테고리

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

제품


릴리스

R14SP2

Community Treasure Hunt

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

Start Hunting!

Translated by