📄 ex2d.m
字号:
%=============================================================% Ex2d: An example for using WaveNet, 2-D Interpolation%=============================================================% By Qinghua Zhang. March, 1994.help ex2decho on% The function to be interpolated y=f(x1,x2)%============================================% A mesh surface of the function f is drawn in the graphics window.[x1,x2] = meshgrid(-1:0.1:1, -1:0.1:1);xmesh = [reshape(x1, 441,1) reshape(x2, 441,1)];ymesh = ex2d_fun(xmesh); % ymesh=f(xmesh)ymesh = reshape(ymesh, 21,21);clf; mesh(x1,x2,ymesh, zeros(size(ymesh))); title('y=f(x1,x2)');pause% The training data%===================x = rand(200,2)*2 - 1; % Randomly generate 200 input patternsy = ex2d_fun(x); % y=f(x)% The input patterns are depicted in the x1-x2 plane.clf; plot(x(:,1), x(:,2), 'o'); title('Input Patterns in x1-x2 Plane')xlabel('x1'); ylabel('x2');% We are going to use a WaveNet to interpolate the data.% You may set the number of wavelets in the network to 8% or choose it on-line with the aid of the FPE criterion.% Call the training procedure%=============================Key = keymenu('Make your choice','Use 9 wavelets','On-line choice');if Key==1 th = wnetreg(y, x, 9, 10, 2); % Use 9 wavelets, 10 iterations, initialization mode 2.else th = wnetreg(y, x, [], 10, 2); end% Examine the result of the interpolation%=========================================% Evaluate the network on another randomly selected input patternsxg = rand(200,2)*2 - 1; % Randomly generate 200 new input patternsyt = ex2d_fun(xg); % yt=f(xg);yg = wavenet(xg, th); clf; plot([yt yg]); %Compare yt and ygtitle('Compare yt and yg'); xlabel('Sample number');ylabel('yt: - yg: --');echo off
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -