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

I am getting this error: can you help me please
Assignment has more non-singleton rhs dimensions than non-singleton subscripts at
OrientationEnd(ind,1) = Table(i,j);
% Finding Orientation ...
Table=[3*pi/4 2*pi/3 pi/2 pi/3 pi/4
5*pi/6 0 0 0 pi/6
pi 0 0 0 0
-5*pi/6 0 0 0 -pi/6
-3*pi/4 -2*pi/3 -pi/2 -pi/3 -pi/4];
% Ridge Ending Orientation ...
for ind = 1:length(CentroidEndX)
Klocal = K(CentroidEndY(ind)-2:CentroidEndY(ind)+2,CentroidEndX(ind)-2:CentroidEndX(ind)+2);
Klocal(2:end-1,2:end-1) = 0;
[i,j] = find(Klocal);
OrientationEnd(ind,1) = Table(i,j);
end
Table is a 5X5 matrix

2 Comments

This will occur if there are more than one items in i and j.
How can i resolve this error ? How can i use the first value of i and j if many values occur ?
Thanks

Sign in to comment.

 Accepted Answer

If you want to use only the first element, you can use the code below. This might still result in an error if no valid positions are found by find.
% Finding Orientation ...
Table=[3*pi/4 2*pi/3 pi/2 pi/3 pi/4
5*pi/6 0 0 0 pi/6
pi 0 0 0 0
-5*pi/6 0 0 0 -pi/6
-3*pi/4 -2*pi/3 -pi/2 -pi/3 -pi/4];
% Ridge Ending Orientation ...
for ind = 1:length(CentroidEndX)
Klocal = K(CentroidEndY(ind)-2:CentroidEndY(ind)+2,CentroidEndX(ind)-2:CentroidEndX(ind)+2);
Klocal(2:end-1,2:end-1) = 0;
[i,j] = find(Klocal);
OrientationEnd(ind,1) = Table(i(1),j(1));
end

More Answers (0)

Categories

Asked:

on 31 Mar 2018

Commented:

on 31 Mar 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!