Assignment has more non-singleton rhs dimensions than non-singleton subscripts
2 views (last 30 days)
Show older comments
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 Comments
José-Luis
on 9 Sep 2017
I don't get why you need a loop. Why don't you just index the values you need.
Answers (1)
KSSV
on 9 Sep 2017
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,:))
See Also
Categories
Find more on NaNs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!