How to optimize parameters that satisfy the equation.

I want to optimize three parameters x, y, z that satisfy the following equation.
A(D) = abs(x * (y * exp(1i * z) * B(D) + C(D)))
A (D), B (D), C (D): Constant determined by D
i : imaginary unit
However, it does not converge to the expected value.
What sholud I do about this situation?
I used the Optimize Live Editor Task with the following contents by referring to the following URL.
https://www.mathworks.com/help/matlab/math/optimize-live-editor-matlab.html
Objective : Nonlinear
Constraints : Unconstrained
Solver : fminsearch
Objective function : Local function, objectiveFcn
Initial point : x0 = [3 2 pi]
This time, A (D) = 0.24, B (D) = 0.05, C (D) = 0.02, and the Local function is described as follows.
At this time, x, y, and z are expected to be 3, 2, pi, respectively.
---------------------------------------------------------
function f = objectiveFcn(optimInput)
x = optimInput(1);
y = optimInput(2);
z = optimInput(3);
f = 0.24 - abs(x*(0.05*y*exp(1i*z) + 0.02));
end
---------------------------------------------------------

 Accepted Answer

First, you must fix the formula for f
f = abs( 0.24 - abs(x*(0.05*y*exp(1i*z) + 0.02)) );
Second, you have 3 unknowns, so you must provide at least 3 equations.

5 Comments

Thank you for your comments.
I fixed the formula.
And concerning 3 equations, in fact A(D), B(D) and C(D) are functions of D,
so it is possible to prepare over 3 equations. (For example, D=100, 200, 300)
In this case, how should the Local function be described?
In the above f measures the violation of one equation. With more than one, you should sum the violations of all equations.
I’m so sorry for taking so long to get back to you.
What does "sum the violations" mean?
I can't understand the meaning of this sentence,
so I don't know what I should do specifically.
I'm sorry to ask you so many questions.
For example, if your equations were the 2x2 system A*x=b
A=rand(2); b=sum(A,2);
f=@(x) sum(abs(A*x-b));
x=fminsearch(f,[0;0])
x = 2×1
1.0000 1.0000
Thank you for your quick reply.
It looks like I will optimize my equations by referring to your example.
Thank you so much again.

Sign in to comment.

More Answers (0)

Products

Release

R2021b

Asked:

KM
on 18 Mar 2022

Commented:

KM
on 22 Mar 2022

Community Treasure Hunt

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

Start Hunting!