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

1 次查看(过去 30 天)
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 个评论
dpb
dpb 2021-1-29
" 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.

请先登录,再进行评论。

采纳的回答

Shubham Khatri
Shubham Khatri 2021-2-3
编辑:Shubham Khatri 2021-2-3
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by