matlab 编写的小波分解程序,进行模式识别
源代码在线查看: untitled9.m
close all
clear
echo on
clc
%NEWFF---生成一个新的前向神经网络
%TRAIN---对BP神经网络进行训练
%SIM-----对BP神经网络进行仿真
%定义训练样本
%P为输入矢量 ,抽取的特征量
P=[87.196 65.8729 76.4657 49.605 96.8476 98.8719
118.5924 96.036 149.6234 125.0301 132.8508 110.6935
124.2915 107.2495 154.1799 137.2761 161.6836 159.9111
129.1929 140.7734 158.8035 146.897 212.0396 186.6519
139.3846 141.6084 202.349 191.3141 251.2583 224.8192
175.6648 162.1239 249.649 263.8072 292.3482 271.8296
237.1847 192.0721 299.2468 293.7939 424.0791 373.3039
415.2695 328.5668 891.0752 843.0593 993.8016 913.002
2.20E+03 2.20E+03 2.44E+03 2.45E+03 2.46E+03 2.47E+03
1.94E+04 1.94E+04 1.53E+04 1.53E+04 1.47E+04 1.48E+04
3.84E+04 3.83E+04 2.94E+04 2.94E+04 2.80E+04 2.84E+04
];
%T为目标矢量
T=[0 0.1 0.2 0.3 0.4 0.5];
%创建一个新的前向神经网络
net=newff(minmax(P),[10,1],{'tansig','purelin'},'trainlm');
%当前输入层权值和总阈值
inputWeights=net.IW{1,1};
inputbias=net.b{1};
%当前网络层权值和阈值
layerWeights=net.LW{2,1};
layerbias=net.b{2};
%设置训练参数
net.trainParam.show=50; %????????
net.trainParam.lr=0.05; %设定修正权值的学习速率 0.01~0.07
net.trainParam.mc=0.9; %????????
net.trainParam.epochs=10000; %设定循环次数
net.trainParam.goal=1e-8; %设定期望误差最小值
%调用TRAINGDM算法训练网络
[net,tr]=train(net,P,T);
x=[87.196 65.8729 76.4657 49.605 96.8476 98.8719
118.5924 96.036 149.6234 125.0301 132.8508 110.6935
124.2915 107.2495 154.1799 137.2761 161.6836 159.9111
129.1929 140.7734 158.8035 146.897 212.0396 186.6519
139.3846 141.6084 202.349 191.3141 251.2583 224.8192
175.6648 162.1239 249.649 263.8072 292.3482 271.8296
237.1847 192.0721 299.2468 293.7939 424.0791 373.3039
415.2695 328.5668 891.0752 843.0593 993.8016 913.002
2.20E+03 2.20E+03 2.44E+03 2.45E+03 2.46E+03 2.47E+03
1.94E+04 1.94E+04 1.53E+04 1.53E+04 1.47E+04 1.48E+04
3.84E+04 3.83E+04 2.94E+04 2.94E+04 2.80E+04 2.84E+04
];
%对BP网络进行仿真
A=sim(net,x)
%计算仿真误差
E=T-A
MSE=mse(E)
echo off