Possibility of Custom Denominator of Transfer Function within Simulink

7 views (last 30 days)
I'm trying to replicate a part of a block diagram and I'm unable to use a normal transfer function block as it only accepts the input signal, and not a varying time constant such as tau_D. I know that I can use a function block and create a code to accept both the input signal and the time varying variable. However, within simulink I'm not able to use the "tf" function as it not supported. I apply state space method, and while the results are within 1-2 Hp, I'm not happy with the time response of the engine ramping up to the desired HP number (See display and scope). It also doesn't start at zero. When I uncomment the rest of the diagram to verify how it integrates with the other blocks within the block diagram, the function block produces the following error:
"Derivative of state '1' in block 'Question_Variable_Transfer_Function/Integrator' at time 0.0 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)"
Essentially, it boils down too two questions:
1.) Is there a block or a function that allows a variable time constant (tau_D) to be inputted into the denominator of the transfer function of the transfer function?
2.) Apart from changing the fixed step size, is there any other way to remove the error simulink is presenting.
I appreciate any guidance or help to mitigate this issue? Thanks in advance.

Accepted Answer

Sam Chak
Sam Chak on 30 Sep 2024
For a variable gain in a dynamic model, you can try describing the system using MATLAB Function block.
%% MATLAB Function block
function dx = odefcn(x, u, tauD)
A = - 1/tauD;
B = 1/tauD;
dx = A*x + B*u;
end
Else, you can trying using the LPV System block. LPV stands for "linear parameter-varying".
For a variable gain , you can use the Divide block where you should feed the signal to the division port (2nd input port).
  2 Comments
Alexander Gaudreau
Alexander Gaudreau on 30 Sep 2024
Hello @Sam Chak:
Thank you for you help! I redid the function block with the code provided and used the divide block and now able to get values. The only thing that concerns me is that the behavior of the curve along with its final value. When compared to a set time constant that is fixed within the test function exhibits different curve behavior. Is there any other tips/tricks that can be done to model this more closely, or is this a limitation? See picture included.
Alexander Gaudreau
Alexander Gaudreau on 30 Sep 2024
Also as a note to anybody who encounters a similar error message problem, you must change under model setting -> model referencing -> total number of instances allowed per top model -> change to one (maybe zero; depends upon application)

Sign in to comment.

More Answers (0)

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!