Effacer les filtres
Effacer les filtres

MPCmove with function and pscad

4 vues (au cours des 30 derniers jours)
영민 공
영민 공 le 22 Juil 2023
I want mpc with pscad, so i want make mpcmove function
function [u,y] = mpcmove_test(r,y)
num=[1 1];
den=[1 1 2];
[A,B,C,D] = tf2ss(num,den);
sys = ss(A,B,C,D);
Ts = 0.05;
p = 10;
m = 10;
% r = 1;
% y = 0;
mpc_contrller = mpc(sys,Ts,p,m);
state = mpcstate(mpc_contrller);
% for i = 1:100
[u] = mpcmove(mpc_contrller,state,y,r);
y = C*state.plant;
% y_p(i,1) = y;
% end
% plot(y_p)
this is my function code, but when i run this fuction with pscad, It can't follow the reference. This means that the value will continue to rise and never stop. I think pscad run this function.
But when i run this code with loop, It works well, why first code works different?
num=[1 1];
den=[1 1 2];
[A,B,C,D] = tf2ss(num,den);
sys = ss(A,B,C,D);
Ts = 0.05;
p = 10;
m = 10;
r = 1;
y = 0;
mpc_contrller = mpc(sys,Ts,p,m);
state = mpcstate(mpc_contrller);
for i = 1:100
[u] = mpcmove(mpc_contrller,state,y,r);
y = C*state.plant;
y_p(i,1) = y;
end
plot(y_p)

Réponses (1)

Shushant
Shushant le 1 Août 2023
I understand that when you try to execute two identical pieces of code, one using a regular loop and the other utilizing a function and using “pscad” but there is disparity in outputs. The difference in outputs is due to the function "mpcmove".
Kindly refer to the following thread to get a better understanding of the issue and possible workaround.
Thank you,
Shushant

Catégories

En savoir plus sur Model Predictive Control Toolbox dans Help Center et File Exchange

Tags

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by