MATLAB: Error encountered after applying vpasolve to solve equations in 3 variables and trying to obtain real values of the unknown variables

image processingrealvpasolve

I've been trying to solve three sets of equations in three unknowns(l1,l2,d) using 'vpasolve' function in matlab for my project in image processing.The different combinations of three equations each should be solved a number of times using for loop.I was trying to obtain real values of l1 and l2 after applying vpasolve for which I used b=S.l1(S.l1==real(S.l1)).I was getting some real values as outputs.But at some point errors and warnings seems to be appearing.
if true
% the values obtained as
b =
-0.0081
-0.0004
-0.0234
-0.0196
-0.0082
-0.0075
-0.0150
-0.0081
-0.0004
-0.0283
-0.0150
-0.0283
-0.0075
-0.0234
-0.0293
-0.0293
-0.0081
-0.0078
-0.0196
-0.0079
-0.0081
-0.0082
-0.0079
-0.0078
c =
-0.0055
0.0011
0.0105
0.0045
-0.0050
-0.0049
0.0060
-0.0055
0.0011
0.0122
0.0060
0.0122
-0.0049
0.0105
0.0163
0.0163
-0.0052
-0.0059
0.0045
-0.0054
-0.0052
-0.0050
-0.0054
-0.0059
%%%warnings and errors
Warning: Solutions might be lost. [solvelib::allvalues_warning]
Comma separated list expansion has cell syntax for an array that is not a cell.
Error in sym/subsref (line 685)
[inds{k},refs{k}] = privformat(inds{k});
Error in SRM_gray (line 189)
S.l1=double(S.l1);
end
if true
%part of code where problem encountered
%%%%%%%%solving equations mathematically
figure,
for i=1:(regions.Count)
%l1=-5:0.1:5;
%l2=-5:0.1:5;
syms l1 l2 d
v1=(((l1*x(1,i))+(l2*y(1,i))+1)^-1);
v2=(((l1*h(1,i))+(l2*g(1,i))+1)^-1);
ua=(v1^2*(x(1,i)^2+y(1,i)^2)+v2^2*(h(1,i)^2+g(1,i)^2)-(2*v1*v2*(x(1,i)*h(1,i)+y(1,i)*g(1,i)))-d^2);%%%eqn 1
for j=(i+1):(regions.Count)
phi= (((l1*x(1,j))+(l2*y(1,j))+1)^-1);
si=(((l1*h(1,j))+(l2*g(1,j))+1)^-1);
ub=(phi^2*(x(1,j)^2+y(1,j)^2)+si^2*(h(1,j)^2+g(1,j)^2)-(2*phi*si*(x(1,j)*h(1,j)+y(1,j)*g(1,j)))-d^2);%%%equation 2
for p=(i+2):(regions.Count)
phi= (((l1*x(1,p))+(l2*y(1,p))+1)^-1);
si=(((l1*h(1,p))+(l2*g(1,p))+1)^-1);
uc=(phi^2*(x(1,p)^2+y(1,p)^2)+si^2*(h(1,p)^2+g(1,p)^2)-(2*phi*si*(x(1,p)*h(1,p)+y(1,p)*g(1,p)))-d^2); %%%%eqn 3
S=vpasolve(ua==0,ub==0,uc==0);
hold on
S.l1=double(S.l1);
S.l2=double(S.l2);
b=S.l1(S.l1==real(S.l1))
c=S.l2(S.l2==real(S.l2))
plot(b,c,'o')
%numeric::solve(u(i)==0,u(j)==0);
% vpa(S.l1);
%vpa(S.l2);
end
end
end
hold off;
end
Kindly help to figure out these errors.

Best Answer

My suspicion is that you are encountering a case where vpasolve() is returning an empty symbolic vector for each solution, reflecting the inability to solve the expression for those inputs.