1、系统辨识作业给两组数据求频谱分析模型一数据一:clcfs=500;t=1/fs:1/fs:1;a=importdata(C:DocumentsandSettingsAdministrator桌面系统辨识数据(两组)model1model1_1_1a.txt);N=length(a);p1=a(:,1);%得到采样输入数据p,下面对p进行频谱分析figure(1)plot(t,p1);gridontitle(输入数据p1);xlabel(t);ylabel(p1)p2=a(:,2);%得到采样输入数据p,下面对p进行频谱分析figure(2)plot(t,p2);gridontitle(输入数据
2、p2);xlabel(t);ylabel(p2)Y1=fft(p1);Y2=fft(p2);Y=Y2./Y1;magY=abs(Y(1:1:N/2)*2/N;f=(0:N/2-1)*fs/N;figure(3)plot(f,magY);h=stem(f,magY,fill,-);set(h,MarkerEdgeColor,red,Marker,*);gridontitle(频谱图);xlabel(f(Hz);ylabel(幅值)去掉h=stem(f,magY,fill,-); set(h,MarkerEdgeColor,red,Marker,*);模型一数据二:clcfs=500;t=1/fs
3、:1/fs:1;a=importdata(C:DocumentsandSettingsAdministrator桌面系统辨识数据(两组)model1model1_1_2a.txt);N=length(a);p1=a(:,1);%得到采样输入数据p,下面对p进行频谱分析figure(1)plot(t,p1);gridontitle(输入数据p1);xlabel(t);ylabel(p1)p2=a(:,2);%得到采样输入数据p,下面对p进行频谱分析figure(2)plot(t,p2);gridontitle(输入数据p2);xlabel(t);ylabel(p2)Y1=fft(p1);Y2=f
4、ft(p2);Y=Y2./Y1;magY=abs(Y(1:1:N/2)*2/N;f=(0:N/2-1)*fs/N;figure(3)plot(f,magY);gridontitle(频谱图);xlabel(f(Hz);ylabel(幅值)模型一数据三:clcfs=500;t=1/fs:1/fs:1;a=importdata(C:DocumentsandSettingsAdministrator桌面系统辨识数据(两组)model1model1_1_3a.txt);N=length(a);p1=a(:,1);%得到采样输入数据p,下面对p进行频谱分析figure(1)plot(t,p1);grid
5、ontitle(输入数据p1);xlabel(t);ylabel(p1)p2=a(:,2);%得到采样输入数据p,下面对p进行频谱分析figure(2)plot(t,p2);gridontitle(输入数据p2);xlabel(t);ylabel(p2)Y1=fft(p1);Y2=fft(p2);Y=Y2./Y1;magY=abs(Y(1:1:N/2)*2/N;f=(0:N/2-1)*fs/N;figure(3)plot(f,magY);gridontitle(频谱图);xlabel(f(Hz);ylabel(幅值)模型二数据一:clcfs=500;t=1/fs:1/fs:1;a=import
6、data(C:DocumentsandSettingsAdministrator桌面系统辨识数据(两组)model2model2_1_1a.txt);N=length(a);p1=a(:,1);%得到采样输入数据p,下面对p进行频谱分析figure(1)plot(t,p1);gridontitle(输入数据p1);xlabel(t);ylabel(p1)p2=a(:,2);%得到采样输入数据p,下面对p进行频谱分析figure(2)plot(t,p2);gridontitle(输入数据p2);xlabel(t);ylabel(p2)Y1=fft(p1);Y2=fft(p2);Y=Y2./Y1;
7、magY=abs(Y(1:1:N/2)*2/N;f=(0:N/2-1)*fs/N;figure(3)plot(f,magY);gridontitle(频谱图);xlabel(f(Hz);ylabel(幅值)模型二数据二:clcfs=500;t=1/fs:1/fs:1;a=importdata(C:DocumentsandSettingsAdministrator桌面系统辨识数据(两组)model2model2_1_2a.txt);N=length(a);p1=a(:,1);%得到采样输入数据p,下面对p进行频谱分析figure(1)plot(t,p1);gridontitle(输入数据p1);
8、xlabel(t);ylabel(p1)p2=a(:,2);%得到采样输入数据p,下面对p进行频谱分析figure(2)plot(t,p2);gridontitle(输入数据p2);xlabel(t);ylabel(p2)Y1=fft(p1);Y2=fft(p2);Y=Y2./Y1;magY=abs(Y(1:1:N/2)*2/N;f=(0:N/2-1)*fs/N;figure(3)plot(f,magY);gridontitle(频谱图);xlabel(f(Hz);ylabel(幅值)模型二数据三:clcfs=500;t=1/fs:1/fs:1;a=importdata(C:Documents
9、andSettingsAdministrator桌面系统辨识数据(两组)model2model2_1_3a.txt);N=length(a);p1=a(:,1);%得到采样输入数据p,下面对p进行频谱分析figure(1)plot(t,p1);gridontitle(输入数据p1);xlabel(t);ylabel(p1)p2=a(:,2);%得到采样输入数据p,下面对p进行频谱分析figure(2)plot(t,p2);gridontitle(输入数据p2);xlabel(t);ylabel(p2)Y1=fft(p1);Y2=fft(p2);Y=Y2./Y1;magY=abs(Y(1:1:N
10、/2)*2/N;f=(0:N/2-1)*fs/N;figure(3)plot(f,magY);gridontitle(频谱图);xlabel(f(Hz);ylabel(幅值)判别系统的阶次;%模型仿真与参数估计%产生输入输出数据clear all;fs=500; t=1/fs:1/fs:1;a=importdata(C:Documents and SettingsAdministrator桌面系统辨识数据(两组)model1model1_1_1a.txt);N=length(a);%数据长度p1=a(:,1); %得到采样输入数据p,下面对p进行频谱分析 figure(1) plot(t,p1
11、); grid on title(输入数据p1); xlabel(t);ylabel(p1)p2=a(:,2); %得到采样输出数据p,下面对p进行频谱分析 figure(2) plot(t,p2); grid on title(输入数据p2); xlabel(t);ylabel(p2)A=1 -1.5 0.7;B=0 1 0.5;C=1 -1 0.2;th0=idpoly(A,B,C);%创建一个armax模型y=sim(th0,p1 p2);%在线模型仿真z=iddata(y,p1);%取得输入输出值figure(3)plot(z)%绘制输入输出曲线%armax模型阶次的估计NN=stru
12、c(1:2,1:2,1:4);Loss_fun=arxstruc(z,z,NN);order=selstruc(Loss_fun,aic);order=order(1),order(2),1,order(3);order; %模型阶次%模型参数的估计Model_para=armax(z,order); %估计armax模型参数 present(Model_para); %显示辨识结果figure(4)compare(z,Model_para) %实际参数与估计参数比较程序结果分析:z=iddata(y,p1)Time domain data set with 500 samples.Sampl
13、ing interval: 1 Outputs Unit (if specified) y1 Inputs Unit (if specified) u1 NN=struc(1:2,1:2,1:4)NN = 1 1 1 1 1 2 1 1 3 1 1 4 1 2 1 1 2 2 1 2 3 1 2 4 2 1 1 2 1 2 2 1 3 2 1 4 2 2 1 2 2 2 2 2 3 2 2 4Loss_fun=arxstruc(z,z,NN)Loss_fun = 1.0e+003 * Columns 1 through 11 0.0002 0.0003 0.0003 0.0003 0.0002
14、 0.0003 0.0003 0.0003 0.0001 0.0001 0.0001 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0020 0.0020 0.0020 0.0010 0.0010 0.0010 0.0010 0.0020 0.0020 0.0020 0.0020 0.0010 0.0010 0.0010 0.0010 0.0020 0.0030 0.0040 0.0010 0.0020 0.0030 0.0040 0.0010 0.0020 0.0030 Columns 12 through 17 0.00
15、01 0.0000 0.0001 0.0001 0.0001 0.4950 0.0020 0.0020 0.0020 0.0020 0.0020 1.4925 0.0010 0.0020 0.0020 0.0020 0.0020 00.0040 0.0010 0.0020 0.0030 0.0040 0order=selstruc(Loss_fun,aic)order = 2 2 1order=order(1),order(2),1,order(3)order = 2 2 1 1orderorder = 2 2 1 1Model_para=armax(z,order)Discrete-time
16、 IDPOLY model: A(q)y(t) = B(q)u(t) + C(q)e(t)A(q) = 1 - 1.507 q-1 + 0.7033 q-2 B(q) = 1.14 q-1 + 0.548 q-2 C(q) = 1 - 0.9697 q-1 Estimated using ARMAX from data set z Loss function 0.0215163 and FPE 0.0219484 Sampling interval: 1present(Model_para)Discrete-time IDPOLY model: A(q)y(t) = B(q)u(t) + C(
17、q)e(t) A(q) = 1 - 1.507 (+-0.003833) q-1 + 0.7033 (+-0.003341) q-2B(q) = 1.14 (+-0.02723) q-1 + 0.548 (+-0.02639) q-2 C(q) = 1 - 0.9697 (+-0.01052) q-1 Estimated using ARMAX from data set z Loss function 0.0215163 and FPE 0.0219484 Sampling interval: 1 Created: 18-Jun-2014 19:51:42 Last modified: 18-Jun-2014 19:53:39
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1