Use griddedInterpolant in MATLAB Function / Alternative to Simulink Functions in For Each Subsystem?
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Long Version (short version of the question below):
I have coded a custom Kalman-Filter-like MATLAB Function which I intend to use in a Simulink model. In order to make the block more universally usable, I used Simulink Function blocks, which contain the respective state space models for the filter. These models are a combination of MATLAB Functions and 2-D Lookup Table blocks. This works quite well for the case of a single model.
However, to make the filter even more universal and modular I intended to use a For Each Subsystem block. I thought, in that way I could use the filter efficiently for multiple similar systems, which use the same model. But the For Each Subsystem does not allow for the use of Simulink Functions.
So I tried to include the model in the filter code (which already compromises universability). However, now I'm facing the problem of using lookup tables within the MATLAB Function. Specifically, I need to use a (preferably efficient griddedInterpolant) 2D lookup table. So here comes the core of my question:
Short Version:
- How can I use griddedInterpolant in a MATLAB Function in Simulink?
- Is there a better alternative way to make my filter block universally usable (preferably with an external model)? i.e. is there an alternative to Simulink Functions for a For Each Subsystem?
Would be great if anynone could help me with this.
Thanks in advance!
0 Commenti
Risposte (1)
Honglei Chen
il 10 Ott 2018
For the first question, the following link shows all supported functions for code generation and griddedInterpolant is not in it, so I don't think you can use it in MATLAB Function Block
However, since it's gridded, you may want to take a look at interp1, interp2, and interpn depending on your use case and these do support codegen.
For the second question, I'm not an expert on For Each Subsystem. But have you considered putting your block in a library so other model can use it?
HTH
Vedere anche
Categorie
Scopri di più su Simulink Functions in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!