a=input('输入分母系数a=[a1,a2,...]=');
n=length(a)-1;
Y0=input('输入初始条件向量?Y0=[y0,Dy0,D2y0,...]=');
b=input('输入输入信号系数b=[b1,b2,...]=');
dt=input('dt=');te=input('te=');
t=0:dt:te;
u=input('输入函数u=');
p=roots(a);V=rot90(vander(p));c=V\Y0';
y1=zeros(1,length(t));
for k=1:n y1=y1+c(k)*exp(p(k)*t);end
te=t(end);
dt=te/(length(t)-1);
[r,p,k]=residue(b,a);
h=r(1)*exp(p(1)*t)+r(2)*exp(p(1)*t);
y2=conv(u,h)*dt;
y=y1(1:length(t))+y2(1:length(t));
figure(1);
subplot(3,1,1),plot(t,y1),grid
xlabel('t'); ylabel('y1');title('零输入响应');
subplot(3,1,2),plot(t,y2(1:length(t)));grid
xlabel('t');ylabel('y2');title('零状态响应');
subplot(3,1,3),plot(t,y),grid
xlabel('t'); ylabel('y');title('全响应响应');
当输入函数u的时候,一直提示未定义函数或变量t。
题目是:已知,对于以下方程y"(t)+2y'(t)+3y(t)=4f'(t)-6f(t),初始值为:y(0-)=2, y'(0-)=7;输入函数为:y=sin(2*t)+cos(5*t),求它的全响应。