Getting Started | ![]() ![]() |
Importing Data from the MATLAB Workspace
This section explains how to import data into a model directly from the MATLAB workspace using the Signal From Workspace block, from the DSP Sources library. This is useful for simulating different kinds of signals and noise.
Simulating a Signal by Importing Data
To import a signal that you create in the workspace, you can use a Signal From Workspace block as a source. An example is the model shown in the following figure. This model is the same as the one shown in the figure Channel Noise Model, except that the Bernoulli Binary Generator block has been replaced with a Signal From Workspace block.
Importing a Signal from the Workspace
To build this model, follow these steps:
channeldoc
at the MATLAB prompt to open the channel noise model. Then save it under a different name in the directory where you keep your work files.
data
(or another variable name).
Before using the model, you must define the vector data
in the MATLAB workspace. For example, type data=randint(1,10^4);
at the MATLAB prompt. This defines data
as a random binary vector of length 104.
Next, select Simulation parameters from the Simulation menu and set the Stop time parameter to length(data)
. When you run a simulation, the model imports the random vector data
into the model.
You can change the vector data
in the MATLAB workspace to simulate a less random signal, or import a signal from outside MATLAB.
![]() | Plotting the Results of Multiple Simulations | Simulating Noise with Imported Data | ![]() |