How to create a function that can work out an input provided the output and and all other variables are known?

3 visualizaciones (últimos 30 días)
I have a function with 6 variables in. 3 of which are fixed values, 2 of which are randomised in a certain domain and then the final variable is the one that needs to be worked out. L1,l1 and h1 are fixed. I want to randomise L2 and h2 and then try and find the corresponding value of l2. However, the value of l2 must make the function equal the function if L1,l1 and h1 were inputted with the already randomised L2 and h2.
To make it easier to describe, I will try and write it out mathematically.
f(L1,l1,h1) = f(random L2, ?l2?, random h2)
However, this needs to be done in one big function containing all the variables like:
f(L1,L2,l1,l2,h1,h2)
To be full, I wil include the values for each vairable.
L1 = 2e-3; l1 = 5e-3; h1 = 0.5e-3;
x = randi([0 10],1,1);
L2 = x.*1e-3;
y = randi([0 1],1,1)
h2 = y.*1e-3;
Again, im not sure if this is 100% clear as it is hard to put into words, if this needs re-explaining I can try and reword it. Thank you for your help in advance.

Respuesta aceptada

Torsten
Torsten el 21 de Jun. de 2022
Editada: Torsten el 21 de Jun. de 2022
Use "fzero" or "fsolve" to solve
G(x) := f(L1,l1,h1) - f(random L2, x, random h2) = 0
for x.
  2 comentarios
aman verma
aman verma el 22 de Jun. de 2022
Im unsure how to set this up using my two functions. Would it be possible that i link my functions and you have a look please?
thank you

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Historical Contests en Help Center y File Exchange.

Productos


Versión

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by