To map all inputs of a Simulink model with data channels of an MDF file in MATLAB, you can use the mdfread function along with the SimulinkModelMapping class. Below is an example code snippet that demonstrates the process:
main.m448 chars18 lines
This code snippet reads in an MDF file (mydata.mdf), loads a Simulink model (my_model), creates a Simulink.ModelMapping object for the model, and then loops through each input port of the model to map the data from the MDF file to the corresponding input port.
For each input port, the code extracts the channel name from the ExtentName property of the Simulink.PortExtent object, uses this to index into the MDF file data structure, and then uses the setVariable method of the mapping object to set the input port data to the corresponding MDF file data.
Note: This code assumes that the MDF file data channels have the same names as the input ports of the Simulink model.
gistlibby LogSnag