Search code examples
matlabmatrixsimulinkcell-array

Heterogeneous data from workspace into Simulink


I have different matrices to import into a Simulink Matlab function from the workspace. These matrices have all different dimension, which I don´t know at priori.

At the beginning I tried using the block 'constant' putting the data all together in a structure like this:

enter image description here

But then, I cannot pick the right matrix since I don´t know the dimension of each element (and also 'mux' cannot be used to split matrices).

I think I will have the same problem also with the block 'from workspace'.

I was wondering if there is a smart way to import heterogeneous structures like these. I tried also with cell-arrays, but it seems to be not supported by Simulink.

Thanks for any suggestions.


Solution

  • If the data is to be used in a Matlab Function block you could define the workspace matricies as parameters in the model explorer and in the Matlab Function port editor. You then have them accessible inside that function without even needing the "const" blocks or drawing any signals.

    Even if your final intent is not to have data into a Matlab Function block those blocks are quite useful for extracting signals from heterogeneous data since you can do some size/type checking in them. Then you can output "simulink friendly" signals for use elsewhere.