![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1742921/image.png)
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 次查看(过去 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 ?
0 个评论
采纳的回答
Siraj
2024-7-30,5:15
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).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1742921/image.png)
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 个)
Vidhi Agarwal
2024-7-30,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:
- 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!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!