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 CenterFile Exchange에서 App Building에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by