matlab2017b
登录后复制
clc;clear;close all;warning off;addpath 'func\'data = xlsread('数据1.xlsx');u = data(:,1:3);x = data(:,4:5);%数据归一化x1= x(:,1);xmin1 = min(x1);xmax1 = max(x1);x2= x(:,2);xmin2 = min(x2);xmax2 = max(x2);x1=(x1)/(xmax1);x2=(x2)/(xmax2);x = [x1,x2];u1= u(:,1);umin1 = min(u1);umax1 = max(u1);u2= u(:,2);umin2 = min(u2);umax2 = max(u2);u3= u(:,3);umin3 = min(u3);umax3 = max(u3);u1=(u1)/(umax1);u2=(u2)/(umax2);u3=(u3)/(umax3);u = [u1,u2,u3];figure;subplot(211);plot(u(:,1),'r');hold onplot(u(:,2),'b');hold onplot(u(:,3),'k');legend('u_1','u_2','u_3');title('归一化数据');subplot(212);plot(x(:,1),'r');hold onplot(x(:,2),'b');legend('x_1','x_2');title('归一化数据');%RNN;[xpre,A,B,C,D] = func_RNN(u,x); figure;subplot(211);plot(x(:,1),'r');hold onplot(xpre(1,:),'b');legend('真实信号','辨识信号');title('RNN效果-辨识');subplot(212);plot(x(:,2),'r');hold onplot(xpre(2,:),'b');legend('真实信号','辨识信号');title('RNN效果-辨识');axis([50,length(x),-1.5,1.5]);figure;subplot(211);plot(x(:,1)-xpre(1,:)','k');title('RNN效果-误差');axis([0,length(x),-0.5,0.5]);subplot(212);plot(x(:,2)-xpre(2,:)','k');title('RNN效果-误差');axis([50,length(x),-0.5,0.5]);mean(abs(x(:,1)-xpre(1,:)'))mean(abs(x(:,2)-xpre(2,:)')) 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.68.69.70.71.72.73.74.75.76.77.78.79.80.81.82.
免责声明:本文系网络转载或改编,未找到原创作者,版权归原作者所有。如涉及版权,请联系删