MPCmove with function and pscad
조회 수: 1 (최근 30일)
이전 댓글 표시
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)
댓글 수: 0
답변 (1개)
Shushant
2023년 8월 1일
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Model Predictive Control Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!