Search code examples
matlabdeep-learningstructuresimulink

How to load non timeseries data into simulink for use in a deep neural network


I trained a neural network in python and want to load the weights into simulink to pass into a function that will build the network. I thought I could use from workspace but it seems it does not handle non time series data for a structure. I get the error.

Invalid structure-format variable specified as workspace input in 'PMSM_FCS_MPC/From Workspace'. If
the input signal is a bus signal, the variable must be a structure of MATLAB timeseries objects.
Otherwise, the variable must include 'time' and 'signals' fields, and the 'signals' field must be a
structure with a 'values' field.

How can I pass a bunch of arrays into a simulink function?

Everything I have seen is about time series data. Nothing on a group of matrices such as would be used in a deep neural network.


Solution

  • The From Workspace block is designed to work with time-series data (as per the error message you show.) There is no need to use it if you have constant data.

    If you have non-time series data and you need it as a Simulink signal then use the name of the MATLAB variable as the parameter in a Constant block. The signal coming out of the block will have the value of your data.

    If you are using a MATLAB Function block then you can also input the data as a parameter argument to the function. See Add Parameter Arguments for the steps to do this.