how to assign x0 value in matlab s-function
古いコメントを表示
Help me, please
when i try to use s-function in a simulink blocket,for identification process parameters using UDRLS algorithm, if i give x0=[1 1] i got output as 1 1. Help me that how to i give x0 value to get correct output.
Following is function i am using
function [sys,x0,str,ts] = estimatorTTTudrls(t,x,u,flag)
switch flag,
%%%%%%%%%%%%%%%%%%
% Initialization %
%%%%%%%%%%%%%%%%%%
case 0,
[sys,x0,str,ts]=mdlInitializeSizes;
%%%%%%%%%%%%%%%
% Derivatives %
%%%%%%%%%%%%%%%
case 1,
sys=mdlDerivatives(t,x,u);
%%%%%%%%%%%
% Outputs %
%%%%%%%%%%%
case 3,
sys=mdlOutputs(t,x,u);
%%%%%%%%%%%%%%%%%%%
% Unhandled flags %
%%%%%%%%%%%%%%%%%%%
case { 2, 4, 9 },
sys = [];
%%%%%%%%%%%%%%%%%%%%
% Unexpected flags %
%%%%%%%%%%%%%%%%%%%%
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
% end wpfun1
%
%
function [sys,x0,str,ts]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 2;
sizes.NumOutputs = 2;
sizes.NumInputs = 9;
sizes.DirFeedthrough = 2;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
%x0=[10;10]
%x0 = [0 1];
str = [];
ts = 1;
% end mdlInitializeSizes
function sys=mdlDerivatives(t,x,u)
%modelparameters zijn nu input
na=1;
nb=1;
nc=0;
d=1;
Fin=1000;
lam1=1;
lam0=1;
% input
u1=u(1); %oC
y=u(2); %oC
x(1)=B;
x(2)=A;
[B,A]=udrls(y,u,na,nb,d,Fin,lam1,lam0);
sys = [x(1); x(2)];
% end mdlDerivatives
function sys=mdlOutputs(t,x,u)
sys = x;
% end mdlOutputs
1 件のコメント
Kaustubha Govind
2014 年 3 月 18 日
Have you tried setting breakpoints in your S-function to debug the issue?
PS: I received a personal message from you for the question. Please be considerate and avoid sending personal messages to contributors on this forum. All users participate voluntarily, and in their spare time. It is forum etiquette to first search for a solution to your problem on the forum to see if it has been answered before. If you do not find a solution, formulate your problem well and post it as a question on the forum. Be patient and allow time for it to be answered. There are some great tips in these discussions: http://www.mathworks.com/matlabcentral/answers/728-how-do-i-write-a-good-question-for-matlab-answers http://www.mathworks.com/matlabcentral/answers/20313-how-to-get-answers-for-my-unanswered-questions
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!