Borrar filtros
Borrar filtros

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?

80 visualizaciones (últimos 30 días)
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 ?

Respuesta aceptada

Siraj
Siraj el 30 de Jul. de 2024 a las 5:15
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.
  1 comentario
Sidhi
Sidhi el 30 de Jul. de 2024 a las 6:33
Hi @Siraj,
Thanks for the answer. I think we can use a "From Workspace" block instead of inports. However, how can we connect the output of the "From Workspace" block to the inport, as the inport block doesn't have any input port to connect?

Iniciar sesión para comentar.

Más respuestas (1)

Vidhi Agarwal
Vidhi Agarwal el 30 de Jul. de 2024 a las 5:02
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:
  1. Prepare the Input data in MATLAB workspace. Ensure that input data is available in the MATLAB workspace.
  2. Add a “From Workspace” Block to Your Simulink Model.
  3. Configure the “From Workspace” Block. Double-click on the “From Workspace” block to open its parameters dialog.
  4. 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.
  5. 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!
  1 comentario
Sidhi
Sidhi el 30 de Jul. de 2024 a las 6:33
Thanks for the answer. I think we can use a "From Workspace" block instead of inports. However, how can we connect the output of the "From Workspace" block to the inport, as the inport block doesn't have any input port to connect?

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by