问题
Background:
A river has a non-constant cross-section. Under standard conditions, the water level amounts h_Std (see figure below).
As it begins to rain, the water level rises until it is equal to h_Rain (see figure below)
After the rain stops, the water level decreases back to the standard water level.
As one can see from the diagrams, the relation between water level and volume is non-constant. However, the function can be desribed mathematically and is known for my particular cross-section of the river.
Problem description:
I want to simulate the water level of the river over time in case of raining. The rain is represented by an signal which can either be 0 (not raining) or 1 (raining) (see red curve in figure below):
The dark-blue parts of the lower diagram are nonlinear and represents the section between h_Std and h_Rain from the diagrams above. The time for completly filling the river is known (t_Fill).
Generaly spoken, I want to activate an user-defined function (in my case the relation between the amount of water / rain and the water level of the river) triggered by an external signal (in my case represented by the "rain"-signal).
How can I obtain such a function (either with a piece of Matlab-Code oder with Simulink blocks)?
回答1:
There are several ways this could be done, one of which is to use enabled subsystems to process the raining and not raining phases. You'd need to change the contents of the 2 subsystems below to reflect your exact height profile in the 2 regions.
来源:https://stackoverflow.com/questions/40190454/matlab-simulink-simulate-filling-and-emptying-of-a-river