I am trying to create an Adaptive Model Predictive control to hold a pendulum at a certain angle (theta), assuming a rotory actuator at the pivot of the pendulum and the mass being connected using a rigid massless rod. I wrote the following file to give the plant dynamics
function y = fcn(u,T)
%% u(1) : Angular Position (rad) u(2) : Angular rate (rad/s)
%T is the applied torque(N/m)
y = zeros([2 1]);
y(1) = u(2); % Angular rate
y(2) = 9.81/0.5*sin(u(1))-T/3/0.5; %Angular Acceleration
Hence the output of the file should be a [2 x 1] matrix, but when I ran the following command
>> set_param(bdroot,'ShowLineDimensions','on')
It showed the line dimension as 2(scalar). What is going wrong here? I fail to understand.
I have attached the Simulink file along with the question.

4 comentarios

Walter Roberson
Walter Roberson el 24 de Feb. de 2020
I suspect that Simulink drops all trailing 1 in the shape.
Dhruv Thakkar
Dhruv Thakkar el 25 de Feb. de 2020
Then why does it show this error.
Error in port widths or dimensions. The signal connected to the "Model.DX" port of the "untitled/Adaptive MPC Controller" block must be a matrix signal of 2 rows and 1 columns.
Component:Simulink | Category:Model error
Error in port widths or dimensions. Output port 1 of 'untitled/Adaptive MPC Controller/MPC/MPC Matrix Signal Check DX/Input' is a one dimensional vector with 2 elements.
Component:Simulink | Category:Model error
weiwei cao
weiwei cao el 2 de Abr. de 2020
Editada: weiwei cao el 2 de Abr. de 2020
I met the same error, so how did you get rid of it?
Thanks a lot~
Dhruv Thakkar
Dhruv Thakkar el 5 de Abr. de 2020
I used the signal dimension block to make sure everything is consistent.

Iniciar sesión para comentar.

 Respuesta aceptada

Jyotsna Talluri
Jyotsna Talluri el 27 de Feb. de 2020

0 votos

The output of the MATLAB function block is by default not set to variable size unless we enable the Variable size check box in the MATLAB Function block editor, in the Edit data of the MATLAB Function block editor, you can specify the output signal size to be [2 1]. But this output is the input to the integrator in the Plant Model subsystem of your model which does not support variable size input. So, use reshape block to convert vector of data to a matrix of required dimensions [2 1], when inputting the output signal from Plant Model to Update Model
Refer to the below link

Más respuestas (0)

Productos

Versión

R2018b

Preguntada:

el 24 de Feb. de 2020

Comentada:

el 5 de Abr. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by