How to optimise a variable to maintain the result of a function at a set value as another variable is increased?

1 Ansicht (letzte 30 Tage)
I have a function: eta_m=R*k*sinc(m*pi*rho*(cos(phi)-sin(phi)*cot((alpha+beta)/2))).^2 where R, m and beta are constants and rho and k are functions dependent on various combinations of the cosine of alpha, phi and beta. As alpha is increased in some range 0 to alpha_max i would like to find the value of phi that maintains eta_m as close to 1/2 as possible. I've looked at the optamisation toolbox but don't really know where to start, any suggestions on how to go about the problem would be appreciated.
Thanks
  2 Kommentare
dpb
dpb am 29 Jan. 2021
" find the value of phi that maintains eta_m as close to 1/2 as possible"
I don't have time to try to mess around with it at the moment, but if there is a solution, you could try
fsolve()
where the function is
fneta_m=fn(r,k) R*k*sinc(m*pi*rho*(cos(phi)-sin(phi)*cot((alpha+beta)/2))).^2 - 0.5;
The above isn't the actual functional you'll need and you may need to write an m-file so you can incorporate the other functional dependencies to get rho and k that are the functionals of alpha, phi, and beta, but the idea is you try to solve for a zero where at 0.5 by subtracting the target value from the function value.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Shubham Khatri
Shubham Khatri am 3 Feb. 2021
Bearbeitet: Shubham Khatri am 3 Feb. 2021
Hello,
To my understanding you want to keep the value of the function contant. You can use fsolve for this. fsolve tries to find the value where the function equals to zero. To modify it to your case we can add a component of subtracting 0.5 from the funtion.
Please take a look at the modified code below
fsolve(R*k*sinc(m*pi*rho*(cos(phi)-sin(phi)*cot((alpha+beta)/2))).^2 - 0.5);
For more information , please visit the documentation of fsolve here
Hope it helps

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by