wnndemo.m
来自「nnToolKit 神经网络工具包是基于 MATLAB 神经网络工具箱自行开发的」· M 代码 · 共 42 行
M
42 行
function retstr = wnndemo()
NNTWARN OFF
retstr=-1;
% 训练数据
% 输入
x = (-1:.05:1)';
% 输出
y = (-2.186 * x - 1.2864) .* (x < -0.2) ...
+ 4.246 * x .* ((x >= -0.2) & (x < 0)) ...
+ (exp(-0.5 .* x - 0.5) .* sin((3 .* x + 7) .* x)) .* (x > 0);
% 绘制输入输出关系图
clf; plot(x,y,'o');
xlabel('x'); ylabel('y'); title('输入输出关系');
% 插值
% 可以在网络中设置小波数或者用FPE规则在线选择
% 训练过程
Key = keymenu('Make your choice','Use 9 wavelets','On-line choice');
if Key==1
th = wnetreg(y, x, 9, 4, 3, 1, 5);
% Use 9 wavelets, 4 iterations, initialization mode 3,
% minimum number of covered data points 1, scanned levels 5.
else
th = wnetreg(y, x, [], 4, 3, 1, 5);
end
% 对结果进行检测
% 对网络进行评价
xg = (-1:.01:1)';
yg = wavenet(xg, th);
% 绘制插值结果
plot(x,y,'o', xg,yg,':'); xlabel('x'); ylabel('y'); title('插值结果');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?