this is a part of my code, I am getting this message. "Unable to perform assignment because the indices on the left side are not compatible with the size of the right side."
1 view (last 30 days)
Show older comments
xa2=linspace(x2(1),x2(2),1000);
ya2 = k(1)*xa2+d(1);
xb2=linspace(x2(2),x2(3),1000);
yb2 = k(2)*xb2+d(2);
xc2=linspace(x2(3),x2(4),1000);
yc2 = k(3)*xc2+d(3);
for i=1:4
if x2(1)<Vrd_il(i) && x2(2)>Vrd_il(i)
index(i) = find(abs(xa2-Vrd_il(i)) < 0.001);
Y_point(i) = ya2(index(i));
AY_L(i) = min(Y_point(i));
elseif x2(2)<Vrd_il(i) && x2(3)>Vrd_il(i)
index(i) = find(abs(xb2-Vrd_il(i)) < 0.001);
Y_point(i) = yb2(index(i));
AY_L(i) = min(Y_point(i));
elseif x2(3)<Vrd_il(i) && x2(3)>Vrd_il(i)
index(i) = find(abs(xc2-Vrd_il(i)) < 0.001);
Y_point(i) = yc2(index(i));
AY_L(i) = min(Y_point(i));
elseif x2(1)>Vrd_il(i)
AY_L(i) = 0;
else
AY_L(i) = 0;
end
end
0 Comments
Accepted Answer
DGM
on 20 Jun 2022
Edited: DGM
on 20 Jun 2022
I'm going to go out on a limb and say that there's no reason to believe that the RHS of this assignment is a scalar.
index(i) = find(abs(xa2-Vrd_il(i)) < 0.001);
if it's not a scalar, then the RHS of this assignment won't be scalar either.
Y_point(i) = ya2(index(i));
The same applies for the other cases.
if you intend to retrieve only the first or last index using find(), you can use the 'first' or 'last' option; otherwise, you'll have to find some other way to deal with the fact that there may be more than one result.
That said, I'm only guessing, since I don't know what any of these variables are or where the error actually occurred. If the above is not the case, then you'll have to reveal the actual complete error message.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!