Is it possible to load the input data from base workspace to the inports in the simulink model without enabling the external input in configuration parameters?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
When working with Simulink models, it is often necessary to input data from external sources for simulation purposes. Typically, this can be done by specifying external inputs in the model's configuration parameters. However, there might be scenarios where you prefer or need to load the input data directly from the MATLAB base workspace to the inport blocks of a Simulink model, without enabling the configuration parameter settings for external inputs.
The input data is already available in the MATLAB workspace so can we directly assign it to the inport block ?
0 commentaires
Réponse acceptée
Siraj
le 30 Juil 2024
Hi @Sidhi
Yes, you can directly assign input data from the MATLAB base workspace to the inport blocks of a Simulink model without enabling the configuration parameter settings for external inputs. This can be done using the "From Workspace" block, which allows you to specify the input data directly from the MATLAB workspace.
Here's how you can achieve this:
1. Ensure that your input data is available in the MATLAB workspace. For example, let's assume you have a time-series input data stored in a variable "inputData".
% Example input data: a sine wave
t = linspace(0, 10, 1000); % Time vector
inputData = [t' sin(t)']; % Time-series data (Nx2 matrix)
2. Open your Simulink model and add a "From Workspace" block to your model. This block will read the input data from the MATLAB workspace.
3. Set the Data parameter of the "From Workspace" block to the name of your workspace variable ("inputData" in this example).
4. Connect the output of the "From Workspace" block to the desired inport block in your Simulink model.
To learn more about the "From Workspace" block, please refer to the documentation at the following link:
By following these steps, you can directly assign input data from the MATLAB workspace to the inport blocks of your Simulink model without enabling the configuration parameter settings for external inputs.
Hope this helps.
Plus de réponses (1)
Vidhi Agarwal
le 30 Juil 2024
Hi Sidhi,
I assume you are asking about a way to input data directly from MATLAB base workspace to the inport blocks of Simulink models without enabling the configuration parameter settings for external inputs.
You can follow given below steps to implement the same:
- Prepare the Input data in MATLAB workspace. Ensure that input data is available in the MATLAB workspace.
- Add a “From Workspace” Block to Your Simulink Model.
- Configure the “From Workspace” Block. Double-click on the “From Workspace” block to open its parameters dialog.
- Connect the “From Workspace” Block to the Inport Block: Connect the output of the “From Workspace” block to the corresponding Inport block in your Simulink model.
- Run your Simulink model. The input data from the MATLAB workspace will be fed into the Inport block via the “From Workspace” block.
For detailed understanding of “From Workspace” block please refer to following documentation.
Hope that Helps!
Voir également
Catégories
En savoir plus sur Sources dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!