フィルターのクリア

Hello, I have problem with my s-function

3 ビュー (過去 30 日間)
Santosh Kumar Choudhary
Santosh Kumar Choudhary 2021 年 9 月 3 日
回答済み: Chunru 2021 年 9 月 4 日
The errors are:
Error in 'Quad4/s-function' while executing MATLAB S-function 'quadrotor_sfcn', flag = 1 (derivatives), at time 0.0.
Dimensions of arrays being concatenated are not consistent.
And this is my s-function:
function [sys,x0,str,ts] = quadrotor_sfcn(t,x,u,flag)
switch flag
% Initialization %
case 0
sizes = simsizes;
sizes.NumContStates = 6;
sizes.NumDiscStates = 0;
sizes.NumOutputs = 3;
sizes.NumInputs = 3;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 1; % at least one sample time is needed
sys = simsizes(sizes);
%
% initialize the initial conditions
%
x0 = [30 0 -20 0 10 0];
%
% str is always an empty matrix
%
str = [];
%
% initialize the array of sample times
%
ts = [0 0];
%%%%%%%%%%%%%%%
% Derivatives %
%%%%%%%%%%%%%%%
case 1
sys=quadrotor(t,x,u);
%%%%%%%%%%%
% Outputs %
%%%%%%%%%%%
case 3
sys = [x(1) x(3) x(5)];
case{2,4,9}
sys=[];
otherwise
error(['unhandledFlag=', num2str(flag)]);
end
% systems details
function xdot=quadrotor(t,x,u)
Jx=4.856*10^-3;
Jy=Jx;
Jz=8.801*10^-3;
Jr=3.357*10^-5;
m=0.468;l=0.225;
g=9.81;a1=(Jy-Jz)/Jx;
a2=Jr/Jx;a3=(Jz-Jx)/Jy;
a4=Jr/Jy;a5=(Jx-Jy)/Jz;
b1=l/Jx;b2=l/Jy;b3=1/Jz;
x1dot=x(2);
x2dot=x(4)*x(6)*a1-x(4)*a2*g+u;
x3dot=x(4);
x4dot=x(2)*x(6)*a3+x(2)*a4*g+u;
x5dot=x(6);
x6dot=x(4)*x(2)*a5+u;
xdot = [x1dot x2dot x3dot x4dot x5dot x6dot];

採用された回答

Chunru
Chunru 2021 年 9 月 4 日
Try the following:
xdot = [x1dot x2dot x3dot x4dot x5dot x6dot]';

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePrepare Model Inputs and Outputs についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by