# I did not understand the error which is called 'Error using symengine: Array sizes must match.' What should i do?

27 views (last 30 days)
Mert Picakci on 16 Jan 2021
Answered: Deepak Meena on 21 Jan 2021
x1=0.2232585;
x2=0.2232585;
iteration=0;
while true
iteration=iteration+1;
syms x1s x2s t
func=(x2s-x1s^2)^2+(1-x1s)^2;
dif_x1=diff(func,x1s);
dif_x2=diff(func,x2s);
a=solve(eqn,t,'Real',true);
val_temp=vpa(subs(func,x1s,x1));
val=vpa(subs(val_temp,x2s,x2));
val_temp_end=vpa(subs(func,x1s,x1));
val_end=vpa(subs(val_temp_end,x2s,x2));
if(val_end>val)
break;
end
end
iteration
Error using symengine
Array sizes must match.
Error in sym/privBinaryOp (line 1013)
args{2}.s, varargin{:});
Error in - (line 7)
X = privBinaryOp(A, B,
'symobj::zipWithImplicitExpansion',
'_subtract');
Error in THE5 (line 26)
I keep getting these errors anyone has a clue?
Star Strider on 17 Jan 2021
My pleasure!
If I can understand what you are doing, I would write a specific solution (and post it as an Answer).

Deepak Meena on 21 Jan 2021
Hi Mert,
The Probelm arises in the 3rd iteration. In the 3rd Iteration x1 is size of 3x1 symfun and grad_x1 is size of 9x1 .
so the line
is throwing error as MATLAB is not able to resolve "x1- grad_x1*t".
So make sure both x1 and grad_x1 are of same size or "x1-grad_x1*t" should make sense like we can subtract 2x2 matrix from 1x2 like this :
syms x1 x2
p = [x1,x2;x2,x1];
t = [x1,x1] - p;
Thanks,
Deepak