You can use several different approaches to load data into a model, including:
Root-level input ports — Import signal data from a workspace, using the Input configuration parameter to import it to a root-level input port of a Inport, Enable, or Trigger block. To import many signals to root-level input ports, consider using the Root Inport Mapping tool, which updates the Input parameter based on the signal data that you import and map to root-level input ports.
Source blocks — Add a source block, such Sine Wave block, to generate signals to input to another block.
From File block — Read data from a MAT-file, outputting the data as a signal.
From Spreadsheet block — Read data from Microsoft® Excel® spreadsheets or CSV spreadsheets, outputting the data as one or more signals.
Signal Builder block — Create interchangeable groups of piecewise linear signal sources to use in a model.
To determine which approach to use, see Comparison of Signal Loading Techniques.
|Inport||Create input port for subsystem or external input|
|Enable||Add enabling port to system|
|Trigger||Add trigger port to model or subsystem|
|From File||Load data from MAT-file|
|From Spreadsheet||Read data from spreadsheet|
|From Workspace||Load signal data from workspace|
|Signal Builder||Create and generate interchangeable groups of signals whose waveforms are piecewise linear|
|Band-Limited White Noise||Introduce white noise into continuous system|
|Chirp Signal||Generate sine wave with increasing frequency|
|Clock||Display and provide simulation time|
|Constant||Generate constant value|
|Enumerated Constant||Generate enumerated constant value|
|Counter Free-Running||Count up and overflow back to zero after reaching maximum value for specified number of bits|
|Counter Limited||Count up and wrap back to zero after outputting specified upper limit|
|Digital Clock||Output simulation time at specified sampling interval|
|Ground||Ground unconnected input port|
|Pulse Generator||Generate square wave pulses at regular intervals|
|Ramp||Generate constantly increasing or decreasing signal|
|Random Number||Generate normally distributed random numbers|
|Repeating Sequence||Generate arbitrarily shaped periodic signal|
|Repeating Sequence Interpolated||Output discrete-time sequence and repeat, interpolating between data points|
|Repeating Sequence Stair||Output and repeat discrete time sequence|
|Signal Generator||Generate various waveforms|
|Sine Wave||Generate sine wave, using simulation time as time source|
|Step||Generate step function|
|Uniform Random Number||Generate uniformly distributed random numbers|
|Waveform Generator||Output waveforms using signal notations|
||Create custom object to map signals to root-level inports|
||Convert contents of MAT-file to Simulink.SimulationData.Dataset object|
||Create custom object to map signals to root-level inports using Simulink mapping mode|
||Create and access Signal Builder blocks|
||Create comma-separated list of variables to map|
||Return initial state structure of block diagram|
||Create MATLAB structures using same hierarchy and attributes as bus signals|
||Create a structure with MATLAB timeseries object leaf nodes|
Understand the techniques available for importing signal data into a model.
Determine the signal loading approach that meets your modeling requirements. In many cases, mapping signal data to root inports works well.
Load data from a workspace and apply it to a root-level input.
To import, visualize, and map signal and bus data to root inports, use the Root Inport Mapping tool.
After associating a scenario with the model, generate a MATLAB® script to perform batch simulations.
Load signal data using a From File block.
Load signal data using a From Workspace block.
Import signal data to a continuous plant model, which uses signal data that is smooth and uninterrupted in time, with a signal data for each time value.
Test a discrete algorithm by importing discrete signals, which are signals that you define using evenly-spaced time values. One signal value is read at each time step, using the sample time of the source block.
When you import signal data for most input test cases, try to minimize the number of time points. The signal data that you load includes samples with ramps and discontinuities.
Load signal logging data that was logged during a previous simulation.
Load signal data that uses units from data logged in a previous simulation. Signal logging, the To File block, and the To Workspace block can include units information for Dataset or Timeseries logging formats.