How to create initial and final values on simulink?
39 views (last 30 days)
Show older comments
Alejandro Morales
on 13 Apr 2016
Commented: Stefan Raab
on 19 Apr 2016
Hello I am currently working on a problem in which I have 5 identical tanks in series. I have found the transfer function of each tank to be of the form 1/(s+1). I am trying to model the system in simulink when the inlet flow concentration of A changes from 0.6 at t=0 to 0.45 when t>0.
The way I am setting it up is to use the step block and set the initial and final value to the ones above and making the step time 0. Then I connect this to 5 transfer functions in series and connect the output to a scope. However, no matter what I try the system always starts at 0 at t =0 and not 0.6 but it always goes to 0.45 after some time. I am new to simulink and don't know what is the correct way to tell the system to start at 0.6 and then go to 0.45.
Do I have to use another type of source block? I have tried everything with the step block and nothing sims to work.
1 Comment
Azzi Abdelmalek
on 13 Apr 2016
Edited: Azzi Abdelmalek
on 13 Apr 2016
Alejandro, try to make your question clear. What initial value? and what final value? what those have to do with a step block? Try just to focus on your real problem. For example telling us that you are connecting the output to the scope has nothing to do with your problem!
Accepted Answer
Stefan Raab
on 18 Apr 2016
Hello,
I suppose you mean the inital values for the transfer function states? This question might be related to your problem: http://de.mathworks.com/matlabcentral/answers/38446-how-to-give-initial-condition-to-transfer-function
NOTE: You will need the " Control System Toolbox" in order to do the following steps.
I would use MATLAB to create your transfer functions with the command
myTF1 = tf(num1,den1);
myTF2 = tf(num2,den2);
...
For more information on the "tf" function, execute the following command in the MATLAB Command Window (this will open the help browser):
web(fullfile(docroot, 'control/ref/tf.html'))
Either you create the combined transfer function for your system directly, or you create the individual transfer functions and then use the "connect" function. More information on "connect":
web(fullfile(docroot, 'control/ref/connect.html'))
As soon as you have the combined transfer function, you can use MATLAB to create a state space model from that:
myStateSpace = ss(myTF);
Use the state space matrices to fill the "Simulink/Continuous/State-Space" block. In the properties of this block you can also specify initial conditions.
I hope this might help you.
Kind regards, Stefan
0 Comments
More Answers (1)
Alejandro Morales
on 19 Apr 2016
1 Comment
Stefan Raab
on 19 Apr 2016
Unfortunately I can't endorse your workaround. Acutally you are adding a constant disturbance to your output signal. This might have the same result as long as you are steady-state accurate, but as soon as you have an input that is not "perfectly suited" to this constant or the plant is more complex, the results are wrong. To underline my words, I made a simple model where the Transfer Function block and the State Space block represent the exact same system, but put the two different step inputs:
As you can see in the plot, the output signals are far from equivalent.
I don't know where your work is leading, but if you don't do this correctly, it may cause many errors in the end and nobody wants that. :)
By the way, you could also build the transfer functions with integrator blocks and feedbacks. The next picture shows the modeling of a PT1 block. In the Integrator block you can then also specify initial conditions:
Kind regards, Stefan
See Also
Categories
Find more on General Applications in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!