Set initial value continuous state in S-function based on an externally defined value
Show older comments
Hey,
I am trying to make an S-function to solve a system of ODEs, so I want to give an initial value to the continuous states to implement the initial conditions. I have given the vector of intial values as an input to the S-function, however in the Start method I can not read the value of the InputPort yet, or atleast it is still set to 0. How do I implement an intial value to a continuous state based on an externally defined value?
I tried to do the following in the Start method, however as I mentioned, all the InputPorts are still set to 0 when this method is called.
function Start(block)
N = block.NumContStates/3;
block.ContStates.Data(1:N) = block.InputPort(4).Data; % initial density
block.ContStates.Data((N+1):(2*N)) = block.InputPort(4).Data .* block.InputPort(5).Data; % intial phi = density*local flow velocity
block.ContStates.Data((2*N+1):(3*N)) = block.InputPort(4).Data .* block.InputPort(6).Data; % initial alpha = density*stagnation interal energy
%end Start
Thank you very much!
Answers (0)
Categories
Find more on Programming 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!