Evaluate parameters in matlab

7 ビュー (過去 30 日間)
AAAA
AAAA 2012 年 5 月 3 日
Dear all If I have flow in terms of pressure, resistance1, resistance2 and capacitance, i.e. flow(P,R1,R2,C) and P and flow are arreys. Now given I know what flow and P are, but I need to find values of R1, R2 and C that can produce the given flow when P is an arbitrary arrey. What function can I use to perform the above task in matlab? Many thanks

採用された回答

Geoff
Geoff 2012 年 5 月 4 日
Presumably you have a formula that calculates flow, given all the other parameters. I am guessing that you have wrapped this into a function: flow(P,R1,R2,C)
Are R1, R2, and C all scalars/constants?
If so, you can easily use fsolve or fminsearch to calculate them, given your known pressure and flows...
Let's say you have measured flow and pressure in F and P, and a function flow(P,R1,R2,C).
I use fminsearch because it's easy to understand and I don't have the optimization toolbox at the moment =)
Then, parameterise the call to flow (using a vector).
pflow = @(P,x) flow(P, x(1), x(2), x(3));
Now objectify this, by saying you want to minimize the sum of square residuals...
objfn = @(P,F,x) = sum((pflow(P,x) - F) .^ 2);
Make a guess at your initial values for R1, R2 and C:
x0 = [ ?, ?, ? ];
And go:
x = fminsearch( @(x) objfn(P,F,x), x0 );
You don't really have to make objfn (or even pflow) accept P and F... You can just make sure they exist before you define these functions... But if you change them, you'll have to redefine the functions and sometimes it's easy to forget that. Using the way I described, you'll always get a fresh P and F when you execute that fminsearch call.
I think fsolve is much the same... But a little more grunty.
  1 件のコメント
AAAA
AAAA 2012 年 5 月 5 日
Thank you very very very very much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by