fsolve stopped because the last step was ineffective

16 ビュー (過去 30 日間)
Yasmine Sellwood
Yasmine Sellwood 2024 年 4 月 23 日
コメント済み: Yasmine Sellwood 2024 年 4 月 23 日
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.

採用された回答

John D'Errico
John D'Errico 2024 年 4 月 23 日
編集済み: John D'Errico 2024 年 4 月 23 日
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])
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.
angles = 1x3
0.1707 0.1707 0.1707
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
angles = fsolve(f,[pi/6, 2*pi/6, 3*pi/6])
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
angles = 1x3
0.2099 0.7263 2.1724
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
f(angles)
ans = 3x1
1.0e-11 * -0.1230 -0.0651 0.6730
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
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)
Equation solved. fsolve completed because the vector of function values is near zero as measured by the value of the function tolerance, and the problem appears regular as measured by the gradient.
ans = 1x3
0.9692 0.7263 0.2099
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
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.
  1 件のコメント
Yasmine Sellwood
Yasmine Sellwood 2024 年 4 月 23 日
Thank you for your help, that explains it.

サインインしてコメントする。

その他の回答 (1 件)

VBBV
VBBV 2024 年 4 月 23 日
移動済み: Bruno Luong 2024 年 4 月 23 日
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])

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by