How to integrate a matlab class in a simulink block?
7 views (last 30 days)
Show older comments
Hello everyone,
In Matlab 2013a, I developed a matlab class named as MyUnitDelay, it has properties "IC,u,y" and methods "initialize,step,update".
classdef MyUnitDelay < handle
properties
IC; %initial condition
u; %input port
y; %output port
end
methods
function initialize(obj,ic)
obj.IC = ic;
obj.u = 0;
obj.y = 0;
end
function y = step(obj,u)
obj.u = u;
obj.y = obj.IC;
y = obj.IC;
end
function obj = update(obj)
obj.IC = obj.u;
end
end
end
I want to create a special Simulink block in which I can create an instance of that class and call appropriate method according to simulation phase.
In this manner;
- What is the most appropriate Simulink block? Level-2 Matlab SFunction/Matlab Function/anything else?I can not use "Matlab System" block since Matlab 2013a version does not support that block.
- Should i derive the class from another superclass according to the block selection? If yes, what should be the superclass?
- I need to generate code from that model. Therefore i need a Simulink block which is supported by Simulink Coder.
0 Comments
Answers (0)
See Also
Categories
Find more on Simulink Functions 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!