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?

조회 수: 7 (최근 30일)
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 ?

채택된 답변

Siraj
Siraj 2024년 7월 30일
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
Sidhi
Sidhi 2024년 7월 30일
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?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Vidhi Agarwal
Vidhi Agarwal 2024년 7월 30일
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
Sidhi
Sidhi 2024년 7월 30일
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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by