Clear Filters
Clear Filters

How to build the Simulink structure of the MPC model?

5 views (last 30 days)
I'm doing this exampleDesign and Cosimulate Control of High-Fidelity Distillation Tower with Aspen Plus Dynamics - MATLAB & Simulink - MathWorks 中国. But I stuck in Cosimulate MPC Controller and Nonlinear Plant Step 2: Build Simulink model for cosimulation. I don't know what is imported into the md(measured disturbance). If I follow the instruction, which is U_nom_pct, it reports error of The matrix variable specified as input for workspace is invalid

Answers (1)

Aditya
Aditya on 21 Mar 2024
The issue you're encountering during the "Cosimulate MPC Controller and Nonlinear Plant" step, particularly at the point of building the Simulink model for cosimulation, seems related to the configuration of the measured disturbance (md) input in your Simulink model. The error message "The matrix variable specified as input for workspace is invalid" suggests there's a problem with how the U_nom_pct variable is being imported or defined in the context of your model.
Let's troubleshoot and resolve this issue step by step:
1. Verify U_nom_pct Variable
First, ensure that the U_nom_pct variable is correctly defined in your MATLAB workspace. This variable should represent the nominal percentage values of manipulated variables (MVs) or inputs to your system and is used to simulate measured disturbances in the model.
  • Check Existence: In MATLAB, use the command whos U_nom_pct to check if the variable exists in your workspace.
  • Check Content: Ensure that U_nom_pct contains valid numeric data that matches the expected format and dimensions for your application.
2. Importing U_nom_pct into Simulink
Assuming U_nom_pct is correctly defined in the MATLAB workspace, the next step is to ensure it's properly imported into Simulink:
  • From Workspace Block: If you're using a "From Workspace" block to import U_nom_pct, ensure the block's data parameter is set correctly. It should match the name of your variable (U_nom_pct). Also, check the format; it might need to be in a specific structure or array format compatible with the block.
  • Signal Dimensions: Ensure that the dimensions of U_nom_pct match the expected input size of the measured disturbance port in your Simulink model. Mismatched dimensions can cause errors.
  • Data Type: Verify that the data type of U_nom_pct (e.g., double, single) is compatible with the rest of your model. Sometimes, explicit type conversion is necessary.
3. Using Constant Block for Static Data
If U_nom_pct represents static data (i.e., not changing over time), you might alternatively use a "Constant" block to input its value into the model. Ensure the value and dimensions are correctly set in the block's parameters.
4. Debugging Tips
  • Model Configuration: Double-check the configuration of the block or method you're using to import U_nom_pct. Incorrect settings can lead to errors.
  • Simulation Parameters: Ensure that your simulation parameters (start time, stop time, solver settings) are correctly configured for the cosimulation.
  • Error Messages: Pay close attention to any error messages or warnings in MATLAB and Simulink. They often provide clues on what might be wrong.
5. Consult Documentation
If you're still stuck, revisiting the documentation or example you're following can be helpful. Ensure you haven't missed any steps or configurations necessary for the cosimulation to work.

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!