Get an input from known function value
Ältere Kommentare anzeigen
Hello,
I hope this is the right place to ask this question.
In a library called Xsteam there is a function s_pT which gives a value, s, from two inputs p and T. I am in a situation where I have a value s and a input value for T but am seeking p. So if the function can be written like this:
s = Xsteam('s_pT',p,T)
And in my case I know that s = 6.5 for an unknown p and T = 600. Which methods can I use to get out p from this situation? Surely that value must be avialiable?
Thank you!
1 Kommentar
dpb
am 12 Dez. 2013
Generally steam properties packages are built with the various routines needed going both directions--known P,T to property or in this case known property, one condition to the other. First thing to do is to make a search for the needed functionality in the package you're using (or find another package that does have the functionality already implemented--shouldn't be very difficult, seems like there are several on File Exchange iirc).
Alternatively, if that's not possible for some reason, use fsolve to solve the problem--implement a function to do it as described above.
Antworten (1)
dpb
am 13 Dez. 2013
To amplify the above since the xsteam package doesn't have all the inverses...\
>> p=fsolve(@(x) xsteam('s_pT',x,600)-6.5,[200],optimset('Display','off'))
p =
202.4734
>> xsteam('s_pT',p,600)
ans =
6.5000
>>
I just got lucky on my guess of initial starting point.
You can obviously generalize the solution by removing the constants from the anonymous function and making them variables. If you need this more than once then wrap it in a function as recommended above.
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!