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

1 vue (au cours des 30 derniers jours)
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.

Réponse acceptée

Torsten
Torsten le 21 Juin 2022
Modifié(e) : Torsten le 21 Juin 2022
Use "fzero" or "fsolve" to solve
G(x) := f(L1,l1,h1) - f(random L2, x, random h2) = 0
for x.
  2 commentaires
aman verma
aman verma le 22 Juin 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
aman verma
aman verma le 22 Juin 2022
i think i have managed to work this out, thank you for your help Torsten!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Historical Contests dans Help Center et File Exchange

Produits


Version

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by