So far I was prototyping in Matlab some signal processing algorithms for biomedical applications. It looks like a batch of .m functions for offline signal processing.
But as the complexity of algorithms increased, I realized that my functions should interact with each other in realtime mode. For example, func1 can detect different events/states and the further work of func2 depends on that events (and vice versa).
Then I found that using Matlab System objects with frame-based concept can help me with that - What Are System Objects?: "For simple, one-time computations use MATLAB functions. However, if you need to design and simulate a system with many components, use System objects."
But when I started to explore this tool, I have encountered some restrictions: In many Matlab examples there are several standard Objects used within a single workflow with equal frame length (a sequence of several step(obj) methods inside a single loop). While in Simulink there are common schemes with standard built-in blocks.
What I need is connection of high-level custom Objects (=stages of algorithm), which can have different frame lengths, can be switched depending on a particular state of the system, and can share some events with each other.
I see two different ways:
- Using simple main script with common variables, step(objects), and several branches, that describe whole system behavour and control management.
- Using Simulink diagrams.
So, my questions are:
- How can I handle different frame lengths? (E.g. one step() of 1k samples -> then 10 steps() of 100 samples -> then waiting data for a step() of 3k samples)
- What are advantages of using Simulink, except graphical representation?
- If using Simulink, where should I keep some common data/parameters and how can I switch workflow between different objects?
Thank you in advance!