Assignment has more non-singleton rhs dimensions than non-singleton subscripts
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
José-Luis
am 9 Sep. 2017
I don't get why you need a loop. Why don't you just index the values you need.
Antworten (1)
KSSV
am 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,:))
1 Kommentar
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!