how can I get the transfer function of this equation using Matlab: dy/dx + K*sqrt(y)-C =0
Show older comments
This is an equation from an inter-acting tanks I used in a closed water circuit microhydro test rig. The first tank is on the ground and has a height of H1. Water is pumped from the first tank. There is a diverting valve that diverts water from the pump back into the first tank at a fraction of the pumped water. The rest of the water from the pump is emtied into the second tank. The height of the water in the second tank is H2. Tank2 it is vertical, and its water exits by gravity into the turbine inside a pipe attached at the bottom of tank2. In detail the system equations are actually:
equation 1: dh1/dt = k1*sqrt(h2) -kp1*(1-x)
equation 2: dh2/dt = kp2*(1-x) -k2*sqrt(1-x)
My problem is to determine if the system is stable or not. In particular, can I use the the transfer function methods to determine the stability of my system?
Accepted Answer
More Answers (1)
Hi Reuel
To determine the stability of your system, you can analyze the transfer function of the system. However, before doing that, you need to linearize the nonlinear equations around an operating point. Once you have the linearized equations, you can obtain the transfer function and analyze its stability.
You can refer to following MATLAB code, I have taken certain assumptions while writing the code. Kindly make necessary changes as per your use case.
% Define symbolic variables for states and inputs
syms h1 h2 kp1 kp2 real
% Define hypothetical system equations (replace these with your actual equations)
f1 = -h1 + kp1 * h2; % Example dynamics for h1
f2 = h2 + kp2 * (1 - h1); % Example dynamics for h2
% Define the system equations vector
F = [f1; f2];
% Define the state vector and input vector
X = [h1; h2];
U = [kp1; kp2];
% Calculate the Jacobians for A and B matrices
A = jacobian(F, X);
B = jacobian(F, U);
% Define operating points for linearization
h1_op = 1;
h2_op = 1;
kp1_op = 0.5;
kp2_op = 0.5;
% Substitute operating points into A and B matrices
A_lin = subs(A, {h1, h2, kp1, kp2}, {h1_op, h2_op, kp1_op, kp2_op});
B_lin = subs(B, {h1, h2, kp1, kp2}, {h1_op, h2_op, kp1_op, kp2_op});
% Convert symbolic matrices to numerical for state-space model
A_num = double(A_lin);
B_num = double(B_lin);
% Assuming direct observation of states and no direct feedthrough
C = eye(2);
D = zeros(2, 2);
% Create the state-space model
sys = ss(A_num, B_num, C, D);
% Display the system for verification
disp('State-space model:');
disp(sys);
% Analyze the stability and transfer function
isStable = isstable(sys);
tf_sys = tf(sys);
disp(tf_sys);
Adding MATLAB documentation for your reference:
Categories
Find more on Chemistry in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
