Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Afficher commentaires plus anciens
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 commentaires
José-Luis
le 9 Sep 2017
And how would you go about "squeezing" them. Please show example input and output?
Obaidur Rehman
le 9 Sep 2017
Modifié(e) : Obaidur Rehman
le 9 Sep 2017
José-Luis
le 9 Sep 2017
I don't get why you need a loop. Why don't you just index the values you need.
Réponses (1)
KSSV
le 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 commentaire
Obaidur Rehman
le 9 Sep 2017
Modifié(e) : Obaidur Rehman
le 9 Sep 2017
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!