Filter löschen
Filter löschen

MPCmove with function and pscad

4 Ansichten (letzte 30 Tage)
영민 공
영민 공 am 22 Jul. 2023
Beantwortet: Shushant am 1 Aug. 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)

Antworten (1)

Shushant
Shushant am 1 Aug. 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

Kategorien

Mehr zu Model Predictive Control Toolbox finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by