Assignment has more non-singleton rhs dimensions than non-singleton subscripts
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi guys,
I am a Matlab newbie. I am trying to squeeze elements from a 3-dimensional matrix on to a 2-dimensional matrix. The size of my 3 dimensional matrix is 11 * 11 * 2871, and it is essentially a variance-covariance matrix with variace reported on the diagonal and covariance appearing on off-diagonals. I am running the following code but it results in the following error
"Assignment has more non-singleton rhs dimensions than non-singleton subscripts"
for i= 1:11
for j = 2:11
corr(i,j) = squeeze(HT(i,j,:))
end
end
Any help would be appreciated. Thanks!
댓글 수: 3
José-Luis
2017년 9월 9일
I don't get why you need a loop. Why don't you just index the values you need.
답변 (1개)
KSSV
2017년 9월 9일
That error appears when you try to store a n dimension in a initialized data which is dimensioned different to n. You try replacing line:
corr(1,2,:) = squeeze(HT(1,2,:))
With exact dimensions of RHS or initialize LHS as a cell.
corr{1,2} = squeeze(HT(1,2,:))
참고 항목
카테고리
Help Center 및 File Exchange에서 NaNs에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!