how to specify additional parameters(vector or matrix) using level2 matlab s-function
Show older comments
here's the level1 s-function,tTime and yStep are both vector parameters:
function [sys,x0,str,ts]= mdlInitializeSizes
if true
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 1;
sizes.NumInputs = 0;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = [];
str =[];
ts = [0 0];
function sys =mdlOutputs(t,tTime,yStep)
i=find(tTime<=t); sys=yStep(i(end));
the problem is that i don't know how write the level2 output function:
function Outputs(block)
if true
i=find(tTime<=t);
block.OutputPort(1).Data = yStep(i(end));
end
the tTime and yStep are vectors specified by user,such as tTime=[0.1 0.2 0.3 0.4]; yStep=[-1 1 0 2];
Answers (0)
Categories
Find more on Block and Blockset Authoring 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!