fsolve stopped because the last step was ineffective
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Yasmine Sellwood
el 23 de Abr. de 2024
Comentada: Yasmine Sellwood
el 23 de Abr. de 2024
Hello, I'm hoping someone can please help me with the below. I'm trying to generate some values for a1, a2 and a3, represented by 'angles'. However the solution is giving me some bizarre values. The code is definitely correct as it is provided from my course, and my values for VDC, V1, V3 and V5 are automatically generated from an external source. Though I don't understand a way to get around this as MATLAB is saying there is no solution.
%% SETTINGS (THE FOLLOWING VALUES SHOULD BE SET TO THE VALUES OBTAINED FROM THE EXCEL FILE)
% First Part
VDC=5.53; % DC-LINK VOLTAGE
V1=2.596; % THE FIRST HARMONIC OF THE OUTPUT VOLTAGE
V3=0; % THE THIRD HARMONIC OF THE OUTPUT VOLTAGE
V5=0.488; % THE FIFTH HARMONIC OF THE OUTPUT VOLTAGE
% Define the nonlinear equations for the angles
f = @(x) [
(4/(pi))*VDC*(sin(x(1))-sin(x(2))+sin(x(3)))-V1;
(4/(3*pi))*VDC*(sin(3*x(1))-sin(3*x(2))+sin(3*x(3)))-V3;
(4/(5*pi))*VDC*(sin(5*x(1))-sin(5*x(2))+sin(5*x(3)))-V5];
% Solve for angles using fsolve
angles = fsolve(f,[pi/6, pi/6, pi/6])
angles = rad2deg(angles)
Then the solution is returns is as follows:
>> finding_alpha_angles
No solution found.
fsolve stopped because the last step was ineffective. However, the vector of function
values is not near zero, as measured by the value of the function tolerance.
<stopping criteria details>
angles =
0.1707 0.1707 0.1707
angles =
9.7817 9.7817 9.7817
Any help is greatly appreciated. Thank you.
0 comentarios
Respuesta aceptada
John D'Errico
el 23 de Abr. de 2024
Editada: John D'Errico
el 23 de Abr. de 2024
This is a common mistake I see being made. You have a problem that has symmetries in it. x(1), x(2), x(3) all play similar parts in the equations. But when you start all three variables out at the same values, you place the solver in a spot that is essentially a saddle point. It sees a locally perfectly flat surface at that location, and while there are places it could go to improve the result, it thinks the objective is flat.
VDC=5.53; % DC-LINK VOLTAGE
V1=2.596; % THE FIRST HARMONIC OF THE OUTPUT VOLTAGE
V3=0; % THE THIRD HARMONIC OF THE OUTPUT VOLTAGE
V5=0.488; % THE FIFTH HARMONIC OF THE OUTPUT VOLTAGE
% Define the nonlinear equations for the angles
f = @(x) [
(4/(pi))*VDC*(sin(x(1))-sin(x(2))+sin(x(3)))-V1;
(4/(3*pi))*VDC*(sin(3*x(1))-sin(3*x(2))+sin(3*x(3)))-V3;
(4/(5*pi))*VDC*(sin(5*x(1))-sin(5*x(2))+sin(5*x(3)))-V5];
% Solve for angles using fsolve
angles = fsolve(f,[pi/6, pi/6, pi/6])
angles = fsolve(f,[pi/6, 2*pi/6, 3*pi/6])
f(angles)
So we see the solver is now happy at the final point (that result is essentially zero to within tolerance trash), even though it could not decide where to go when you started it out at your initial choice. One solution can be to use a perturbational randomizer as a start point.
fsolve(f,[pi/6, pi/6, pi/6] + randn(1,3)*0.1)
And you see there, we get again a solution, but curiously, the solution is the same one we had before, but in a different sequence, because I started it from a randomly different location. This just reinforces what I said before. The problem is perfectly symmetrical.
Más respuestas (1)
VBBV
el 23 de Abr. de 2024
Movida: Bruno Luong
el 23 de Abr. de 2024
The problem seems to occur if you have the same initial conditions for all the angles. Try giving different initial conditions/values instead of same value . E,g,
angles = fsolve(f,[pi, pi/6, pi/3])
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!