Get an input from known function value
이전 댓글 표시
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
dpb
2013년 12월 12일
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.
답변 (1개)
dpb
2013년 12월 13일
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.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!