Email: [email protected]

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/Simulink error “variable-size matrix but its size is specified as inherited or fixed”

Simulink error “variable-size matrix but its size is specified as inherited or fixed”

PuTI / 2025-01-28
Simulink error “variable-size matrix but its size is specified as inherited or fixed”
Matlab News

I’m building a MPC controller for a state space plant (, , with , , ).
I implemented the MPC as Matlab function, whose inputs are
enable (a flag that enables the controller. If it is equal to false, then the outputs are set equal to zero);
X_ref (a vector of size , with the reference state value for each step in the prediction horizon );
U_ref (a vector of size , with the reference input value for each step in the prediction horizon );
x_k ( a vector of the current state );
mpc (a structure with the data for the MPC implementation and all the preprocessed matrices; this is the only function input of type "parameter data"; it’s value is read from matlab workspace).
The output is the vector , that is the control action for the plant. It is constructed in the following way
function u_k = mpc_controller(enable, X_ref, U_ref, x_k, mpc)
if enable
…

[z_opt, ~, flag] = quadprog((H+H’)./2, f, Ain, bin, Aeq, beq, lb, ub, [], options);

else
idx = 1;
z_opt = zeros(mpc.nu, 1);
end

u_k = z_opt(idx:(idx+mpc.nu-1));
where mpc.nu is , while idx is a index appositely constructed in the code.

The same function works perfectly when running in Matlab, but once exported into simulink in the Matlab function, the following error rises:
Error: ‘u_k’ is inferred as a variable-size matrix, but its size is specified as inherited or fixed. Verify ‘u_k’ is defined in terms of non-tunable parameters, or select the ‘Variable Size’ check box and specify the upper bounds in the Size box.

I fixed the u_k value in the property inspector (inside the matlab function block) equal to mpc.nu, that is the actual length of the output, since it cannot have the feature "variable size" because one of the block in series with the matlab function block is a demux.
Do you have any idea on how to manage this problem? Thanks in advanceI’m building a MPC controller for a state space plant (, , with , , ).
I implemented the MPC as Matlab function, whose inputs are
enable (a flag that enables the controller. If it is equal to false, then the outputs are set equal to zero);
X_ref (a vector of size , with the reference state value for each step in the prediction horizon );
U_ref (a vector of size , with the reference input value for each step in the prediction horizon );
x_k ( a vector of the current state );
mpc (a structure with the data for the MPC implementation and all the preprocessed matrices; this is the only function input of type "parameter data"; it’s value is read from matlab workspace).
The output is the vector , that is the control action for the plant. It is constructed in the following way
function u_k = mpc_controller(enable, X_ref, U_ref, x_k, mpc)
if enable
…

[z_opt, ~, flag] = quadprog((H+H’)./2, f, Ain, bin, Aeq, beq, lb, ub, [], options);

else
idx = 1;
z_opt = zeros(mpc.nu, 1);
end

u_k = z_opt(idx:(idx+mpc.nu-1));
where mpc.nu is , while idx is a index appositely constructed in the code.

The same function works perfectly when running in Matlab, but once exported into simulink in the Matlab function, the following error rises:
Error: ‘u_k’ is inferred as a variable-size matrix, but its size is specified as inherited or fixed. Verify ‘u_k’ is defined in terms of non-tunable parameters, or select the ‘Variable Size’ check box and specify the upper bounds in the Size box.

I fixed the u_k value in the property inspector (inside the matlab function block) equal to mpc.nu, that is the actual length of the output, since it cannot have the feature "variable size" because one of the block in series with the matlab function block is a demux.
Do you have any idea on how to manage this problem? Thanks in advance I’m building a MPC controller for a state space plant (, , with , , ).
I implemented the MPC as Matlab function, whose inputs are
enable (a flag that enables the controller. If it is equal to false, then the outputs are set equal to zero);
X_ref (a vector of size , with the reference state value for each step in the prediction horizon );
U_ref (a vector of size , with the reference input value for each step in the prediction horizon );
x_k ( a vector of the current state );
mpc (a structure with the data for the MPC implementation and all the preprocessed matrices; this is the only function input of type "parameter data"; it’s value is read from matlab workspace).
The output is the vector , that is the control action for the plant. It is constructed in the following way
function u_k = mpc_controller(enable, X_ref, U_ref, x_k, mpc)
if enable
…

[z_opt, ~, flag] = quadprog((H+H’)./2, f, Ain, bin, Aeq, beq, lb, ub, [], options);

else
idx = 1;
z_opt = zeros(mpc.nu, 1);
end

u_k = z_opt(idx:(idx+mpc.nu-1));
where mpc.nu is , while idx is a index appositely constructed in the code.

The same function works perfectly when running in Matlab, but once exported into simulink in the Matlab function, the following error rises:
Error: ‘u_k’ is inferred as a variable-size matrix, but its size is specified as inherited or fixed. Verify ‘u_k’ is defined in terms of non-tunable parameters, or select the ‘Variable Size’ check box and specify the upper bounds in the Size box.

I fixed the u_k value in the property inspector (inside the matlab function block) equal to mpc.nu, that is the actual length of the output, since it cannot have the feature "variable size" because one of the block in series with the matlab function block is a demux.
Do you have any idea on how to manage this problem? Thanks in advance simulink, matlab function, variable-size matrix MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

Generate ST code from a look-up table with CONSTANT attribute
2025-05-22

Generate ST code from a look-up table with CONSTANT attribute

“no healthy upstream” error when trying to access My Account
2025-05-22

“no healthy upstream” error when trying to access My Account

MATLAB Answers is provisionally back?
2025-05-21

MATLAB Answers is provisionally back?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: [email protected]
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term

This Application Package for internal Telkom University only (students and employee). Chiers... Dismiss