在MATLAB仿真中,为什么老是说Undefined function or variable 'x'. ?
我是做单神经元PID控制器仿真,这的S函数如下:function[sys,x0,str,ts]=PID(t,x,u,flag,deltak)switchflag,&nbs...
我是做单神经元PID控制器仿真,这的S函数如下:function [sys,x0,str,ts]=PID(t,x,u,flag,deltak)switch flag, case 0 [sys,x0,str,ts] =mdlInitializeSizes; case 2 sys = mdlUpdates(t,x,u,deltak); case 3 sys=mdlOutputs(t,x,u); case {1,4,9} sys = []; otherwise error(['Unhandled flag = ',num2str(flag)]);end;function [sys,x0,str,ts] = mdlInitializeSizes ;sizes = simsizes;sizes.NumContStates = 0;sizes.NumDiscstates = 3;sizes.NumOutputs=1;sizes.NumInputs=4;sizes.DirFeedthrough =1;sizes.NumSampleTimes=1;sys = simsizes(sizes);x0 = [0;0;0];str = [ ];ts = [-1 0];% when flag=2,updates the discrete states function sys =mdlUpdates(t,x,u,deltaK)sys=x+deltaK*u(1)*u(4)*(2*u(1)-u(2));% when flag=3,computates the output signalsfunction sys = mdlOutputs(t,x,u)xx= [u(1)-u(2) u(1) u(1)+u(3)-2*u(2)];sys=[u(4)+0.12*xx*x/sum(abs(x)); x/sum(abs(x))]; 搭好模块之后,双击S-Function模块,在S-Function name:输入PID在S-Function parameters:输出入 X 然后运行系统,老是说 Error evaluating parameter 'x' in 'untitledd1226/S-Function': Undefined function or variable 'x'.请高手指点,不胜感激!
展开
3个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询