Azzera filtri
Azzera filtri

help me, please, i got same output for all input in matlab s-function

2 visualizzazioni (ultimi 30 giorni)
Help me for this
when i try to use the following s-function in a simulink blocket,for identification process parameters using UDRLS algorithm, i got output as B=1 and A=1
for this below function i chahged x0 and if give x0=[1000;1000] i got B=1000 and A=1000 if i change x0=ones(2,1) i got B=1 and A=1 and if i change x0=zeros(2,1) i got B=0 and A=0. what is the error i made i dont know 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 % %============================================================================= % mdlInitializeSizes % Return the sizes, initial conditions, and sample times for the S-function. %============================================================================= % 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=[2;2] %x0 = zeros(2,1); str = []; ts = [0 0]; % end mdlInitializeSizes % %============================================================================= % mdlDerivatives % Return the derivatives for the continuous states. %============================================================================= % 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); %xdot(1)=(1/C1)* ( ( Ti -x(1))/R1 - (x(1)-x(2))/R2 ); %xdot(2)=(1/C2)* ( (x(1)-x(2))/R2 - (x(2)- Te)/R3 ); sys = [x(1); x(2)]; % end mdlDerivatives % %============================================================================= % mdlOutputs % Return the block outputs. %============================================================================= % function sys=mdlOutputs(t,x,u) sys = x; % end mdlOutputs
for this function i chahged x0 and if give x0=[1000;1000] i got B=1000 and A=1000 if i change x0=ones(2,1) i got B=1 and A=1 and if i change x0=zeros(2,1) i got B=0 and A=0. what is the error i made i dont know

Risposte (0)

Categorie

Scopri di più su Block and Blockset Authoring in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by