Solve function. Warning: Explicit solution could not be found.
Mostra commenti meno recenti
I'm working with a system of quadratic equations, my experiment has to go different lines from an initial distance Dist (1) and reach a distance 0.
The problem is that this code only reaches a minimum of approximately 0.00025.
It is a limitation of the solve function? or am I doing something wrong?
Of course, thank you very much.
Here is the code:
function SolveEcu()
% Coordenadas crom�ticas grises
xg = 0.229;
yg = 0.348;
ug = 0.136;
vg = 0.466;
i=1;
Dist(i) = 0.001; %Distancia inicial.
while Dist(i) > 0
syms ucTemp vcTemp
S = solve((vcTemp == (-0.1209*ucTemp) + 0.4827), (Dist(i)^2 == ((ucTemp-ug)^2+(vcTemp-vg)^2)), 'Real', true); %Resuelvo el sistema de ecuaciones
uTemp = S.ucTemp;% Lo uso para evaluar
vTemp = S.vcTemp;
save(['E:\Labz\Experimento Color\Resultados\',datestr(now,'yymmdd')],'uTemp','vTemp','Dist');
i=i+1;
Dist(i)=Dist(i-1)- 0.00001;
disp(['Running.. i=',num2str(i)])
end
pause(0.5);
end
Matlab console:
Running.. i=76
d =
2.5000e-04
Warning: Explicit solution could not be found.
> In solve at 169 In SolveEcu at 17
Comma separated list expansion has cell syntax for an array that is not a cell.
Error in sym/subsref (line 1575) [inds{k},refs{k}] = privformat(inds{k});
Error in SolveEcu (line 19) uTemp = S.ucTemp;% Lo uso para evaluar
>>
Risposte (1)
Roger Stafford
il 12 Dic 2013
In the equation
Dist(i)^2 == (ucTemp-ug)^2+(vcTemp-vg)^2
when the right side of the equation
vcTemp == -0.1209*ucTemp + 0.4827
is substituted for vcTemp, it can be shown by completing the square that the smallest possible real value of the resulting quadratic in ucTemp is about 6.54e-8. Eventually your while-loop will reduce Dist(i)^2 to the point where Dist(i) is still positive but Dist(i)^2 is below 6.54e-8. At this point your equations will have no real solutions. I suspect it is at this time that the 'solve' function issues its error message that no explicit solution could be found since you are requiring a real result. You can find out if this is true by running your code while using the debugger.
Whether or not this is the source of the error message, it is a definite coding mistake which should be corrected. You should make sure that for every value of Dist(i) you present to 'solve' there is a real solution to avoid error messages. Either that or you should not require the solutions to be real.
Categorie
Scopri di più su Numeric Solvers in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!