Evaluate parameters in matlab

7 次查看(过去 30 天)
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.

更多回答(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