S-Function Error flag Error

3 ビュー (過去 30 日間)
lokman alici
lokman alici 2020 年 6 月 7 日
コメント済み: lokman alici 2020 年 6 月 7 日
function [sys,x0,str,ts] = PID(t,x,u,flag)
switch flag,
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
case 3,
sys=mdlOutputs(t,x,u);
case{1,2,4,9}
sys=[];
otherwise
error('UnhandledFlag=', num2str(flag));
end
function [sys,x0,str,ts]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 3;
sizes.NumInputs = 7;
sizes.DirFeedthrough = 1;
sizes.NumSampleTimes = 1; % at least one sample time is needed
sys = simsizes(sizes);
x0 = [];
str = [];
ts = [0 0];
function sys=mdlOutputs(t,x,u)
global kp ki kd
kp=5;
ki=0,0001;
kd=50;
ex=u(1);
ey=u(2);
tpex=u(3);
tpey=u(4);
dhex=u(5);
dhey=u(6);
pdthe=u(7);
V=kp*[ex;ey]+ki*[tpex;tpey]+kd*[dhex;dhey];
u1=V'*[0;1]+pdthe;
u2=V'*[-sqrt(3)/2;-0,5]+pdthe;
u3=V'*[-sqrt(3)/2;-0,5]+pdthe;
%u4=V'*[-sqrt(3)/2;-0,5]+pdthe;
%u5=V'*[-sqrt(3)/2;-0,5]+pdthe;
sys(1)=u1;
sys(2)=u2;
sys(3)=u3;
I get a error like that: How can I solve?
An error occurred while running the simulation and the simulation was terminated
Caused by:
  • Error in 'omnirobotcontrol/S-Function' while executing MATLAB S-function 'PID', flag = 3 (output), at time 0.0.
  • Dimensions of arrays being concatenated are not consistent.

採用された回答

Walter Roberson
Walter Roberson 2020 年 6 月 7 日
-0,5 is a vector with two elements, not negative 1/2
  1 件のコメント
lokman alici
lokman alici 2020 年 6 月 7 日
thank a million!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePID Controller Tuning についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by