I made a mistake in running my own simulation program Error in default port dimensions function of S-function 'sector_controller_new_2018/MATLAB Function'. This function does
1 次查看(过去 30 天)
显示 更早的评论
function [u,y,w,sigma_new,abs_s,delta_x] = Sector_Controller(X,sigma)
A=[-2.3*10^11 314 10^12 0 -10^12 0;-314 -2.3*10^11 0 10^12 0 10^-12;-32258.06 0 -14 314 0 0;0 -100 -314 -14 0 0;10 0 0 0 -1 314;0 10 0 0 -314 -1];
B=[0 0;0 0;100 0;0 100;0 0;0 0];
Q = eye(6);
r = 0.5;
alfa = 0.5;
K = 10;
P=[2.44951548360907e-12 -2.09165190656922e-18 1.96565626557397e-06 4.36981987182490e-09 -1.96578858910451e-06 -4.41839730200147e-09;-2.09165190656922e-18 2.17391304277224e-12 -1.49200064125605e-11 2.67458282398608e-12 2.11065001878914e-11 1.05074460964663e-11; 1.96565626557397e-06 -1.49200064125605e-11 14.0194186403962 0.0311706176768134 -14.0204921715724 -0.0315159183650968;4.36981987182490e-09 2.67458282398608e-12 0.0311706176768134 0.0173304826437532 -0.0444472867337676 0.0174287895866309;-1.96578858910451e-06 2.11065001878914e-11 -14.0204921715724 -0.0444472867337676 14.4400524852663 0.0410385906524375;-4.41839730200147e-09 1.05074460964663e-11 -0.0315159183650968 0.0174287895866309 0.0410385906524375 0.415959296205301];%icare(A,B,Q,R)
S=B'*P;
s = S*X;
abs_s = abs(s); % norm of s(x)
Delta = r*Q;
delta_x = (X'*Delta*X)^(0.5);
if abs_s <= alfa*delta_x
sigma_new = 0; y = 0;
elseif abs_s > alfa*delta_x && abs_s <= delta_x
sigma_new = sigma; y = -5;
else
sigma_new = 1; y = -10;
end
w = (S*B)^(-1)*(S*A*X+K*s);
u = -sigma_new*(S*B)^(-1)*(S*A*X+K*s);
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Block Libraries 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!