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

1 view (last 30 days)
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.

Accepted Answer

Torsten
Torsten on 21 Jun 2022
Edited: Torsten on 21 Jun 2022
Use "fzero" or "fsolve" to solve
G(x) := f(L1,l1,h1) - f(random L2, x, random h2) = 0
for x.

More Answers (0)

Categories

Find more on Historical Contests in Help Center and File Exchange

Products


Release

R2015b

Community Treasure Hunt

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

Start Hunting!