フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to define x-vectorm in M S-Function

2 ビュー (過去 30 日間)
Ted
Ted 2013 年 1 月 13 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi a question
i cant understand how defined x-vector in m s-function (in simulink loop) ... and what process done on input in my sample m s-function code. input is a step function.my sample code is below
help please
function [sys,x0] =FT_Ball(t,x,u,flag)
%global kb
kb=12;
switch flag
case 1
sys(1)=3*x(2);
sys(2)=x(3);
sys(3)=(kb^3*u- 5*kb*x(3) - 6*kb^2*x(2)-kb^3*x(1));
case 3
sys(1)=x(1);
case 0
sys=[3,0,1,1,0,0];
x0=[0,0,0];
case {2,4,9} sys=[];
end

回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2013 年 1 月 14 日
You are required to return your computed states (the vector x) in Case 2 (mdlUpdate). Please read Maintain Level-1 MATLAB S-Functions for information on how each Case (method) is executed.
Also, it is highly recommended that you write a Level-2 MATLAB S-function instead of Level-1 (which is what you're writing) when creating a new S-function. The Level-1 interface was deprecated several releases ago and may not be supported in future releases of Simulink.

この質問は閉じられています。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by