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

조회 수: 1 (최근 30일)
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.

채택된 답변

Torsten
Torsten 2022년 6월 21일
편집: Torsten 2022년 6월 21일
Use "fzero" or "fsolve" to solve
G(x) := f(L1,l1,h1) - f(random L2, x, random h2) = 0
for x.
  댓글 수: 2
aman verma
aman verma 2022년 6월 22일
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 2022년 6월 22일
i think i have managed to work this out, thank you for your help Torsten!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Historical Contests에 대해 자세히 알아보기

제품


릴리스

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by