"Assignment has more non-singleton rhs dimensions than non-singleton subscripts"

3 views (last 30 days)
Hey all, having the problem "Assignment has more non-singleton rhs dimensions than non-singleton subscripts" as stated above.
Firstly, I know what this problem means and where the error is occuring, I just cannot figure out a solution for it.
My code is as followed:
a0 = [0 0 0];
b0 = a0/3 .* [1 1 1];
a1 = a0/2 .* [0 1 1];
a2 = a0/2 .* [1 0 1];
a3 = a0/2 .* [1 1 0];
In = n .*a1 + m .*a2 + l .*a3;
P = n .*a1 + n .*a2 + l .*a3 + b0;
for n = 1:5
for m = 1:5
for l = 1:5
In(n+1,m+1,l+1,:) = a0;
P(n+1,m+1,l+1,:) = a0 + b0;
end
end
end
The error occurs in:
In(n+1,m+1,l+1,:) = a0;
  3 Comments
Torsten
Torsten on 20 Jun 2016
Note that the lines
In = n .*a1 + m .*a2 + l .*a3;
P = n .*a1 + n .*a2 + l .*a3 + b0;
are superfluos and that you can get the same result for In and P if you just initialize them to zero:
In = zeros(6,6,6,3);
P = zeros(6,6,6,3);
Best wishes
Torsten.

Sign in to comment.

Answers (0)

Categories

Find more on Creating and Concatenating 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!