## Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

### tomas lineros (view profile)

on 12 Jul 2018
Latest activity Edited by Adam Danz

on 22 May 2019
for i=1:(Num_Ele+Num_Res);
for j=1:(Num_Ele+Num_Res);
for k=1:length(conn);
ind1=conn(k,1);
ind2=conn(k,2);
F(i)=xy(ind2,:)-xy(ind1,:);
A(i,j)= acos(dot(F(k,:),[1,0])/norm(F(k,:)));
end
end
end

### Products

on 12 Jul 2018

on 22 May 2019

You're trying to put x items in y spaces. For example, in the lines below I'm trying to put 3 numbers in 1 space.
x = [10,11,12,13,14];
x(1) = [7,8,9]; % Error!
Here's another example where I try to put 3 items in two spaces.
x = {'d' 'e' 'f' 'g' 'h'};
x(1:2) = {'a','b','c'}; % Error!
One more example with a matrix. Here I try to replace the first row [1,2,3] with [1,2,3,4]
x = [1 2 3;
4 5 6;
7 8 9];
x(1,:) = [1 2 3 4]; % Error!
These are indexing errors.
In your case, if F and A are vectors or matrices then you can only store one value (a scalar) in F(i) and one value in A(i,j). Without knowing what your variable are, I can only guess that this line below produces a vector.
xy(ind2,:)-xy(ind1,:);
So you might be trying to store >1 value in F(i). The same is probably true to A(i,j).
If F and A are cell arrays, then you can store a vector or matrix (and more) into a single element F{i}
So, you need to look at the values you are attempting to store in F(i) and A(i,j) to determine if they are scalars or not.