Assignment has more non-singleton rhs dimensions than non-singleton subscripts error.

3 views (last 30 days)
for i=1:10201
SemivariancePredicSample_ST(i,:)=(GlobalSill-(T_x(1).*(1-exp(-(DistPredicSample_T.^2)/(T_x(2).^2)))+S_x(1).*(1.5*(DistPredicSample_S(i,:)/S_x(2))-0.5*(DistPredicSample_S(i,:).^3/S_x(2).^3)) ...
-((T_x(1)+S_x(1)-GlobalSill)/(T_x(1)*S_x(1)))*(T_x(1).*(1-exp(-(DistPredicSample_T.^2)/(T_x(2).^2)))).*(S_x(1).*(1.5*(DistPredicSample_S(i,:)/S_x(2))-0.5*(DistPredicSample_S(i,:).^3/S_x(2).^3)))))';
end
I get the error Assignment has more non-singleton rhs dimensions than non-singleton subscripts.
What to do?

Accepted Answer

Rik
Rik on 6 Nov 2017
Check for typos. This error occurs when the size of the left hand doesn't match the size on the right hand. (there are more dimensions that are not 1 (non-singleton) right hand side (rhs) than there are in the part of the array (the subscript) where you are trying to save it in)
The code below will trigger such an error, and here it is easy to see what is happening:
a=rand(4,4);
a(:,1)=rand(4,1,4);

More Answers (0)

Categories

Find more on Resizing and Reshaping Matrices 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!