Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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 comentarios
dpb
dpb el 29 de En. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Shubham Khatri
Shubham Khatri el 3 de Feb. de 2021
Editada: Shubham Khatri el 3 de Feb. de 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

Más respuestas (0)

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by