⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xlinpred.m

📁 实用化工计算机模拟:MATLAB在化学工程中的应用 附录光盘程序
💻 M
字号:
% LinPred.m 
%  Linear prediction.
%  用NEWLIND设()计一个线性网络,用SIM()对此线性网络进行仿真。 
%  网络利用过去五个信号值可以对下一个信号进行预测。
%
%   Author: HUANG Huajiang
%   Copyright 2003 UNILAB Research Center, 
%   East China University of Science and Technology, Shanghai, PRC
%   $Revision: 1.0 $  $Date: 2003/01/12 $
%
%   [Ref] MATLAB demo, Mathworks Co.

clear all

% (1) Defining a wave form 
% ------------------------
% TIME defines the time steps of this simulation.
time = 0:0.025:5;  % from 0 to 6 seconds

% T defines the signal in time to be predicted:
t = sin(time*4*pi);
q = length(t);

% The input p to the network is the last five values of the signal T:
p = zeros(5,q);
p(1,2:q) = t(1,1:(q-1));
p(2,3:q) = t(1,1:(q-2));
p(3,4:q) = t(1,1:(q-3));
p(4,5:q) = t(1,1:(q-4));
p(5,6:q) = t(1,1:(q-5));

% (2)Plotting the signals to be predicted
% ---------------------------------------
plot(time,t)
xlabel('Time');
ylabel('Target Signal');
title('Signal to be Predicted');

% (3)Design the network...
% NEWLIND solves for weights and biases which will let
% the linear neuron model the system.
net = newlind(p,t);

% (4)Testing the predictor 
% ------------------------
% SIM simulates the linear neuron which attempts
% to predict the next value in the signal at each timestep
a = sim(net,p);

% (5)绘制输出信号(Plotting the Output Signal)
% ----------------------------------------
% 绘制输出信号和目标信号
plot(time,a,time,t,'+')
xlabel('Time');
ylabel('Output -  Target +');
title('Output and Target Signals');

% 绘制神经元输出信号与目标信号之差,以便观察预测性能 
figure
e = t - a;
plot(time,e)
hold on
plot([min(time) max(time)],[0 0],':r')
hold off
xlabel('Time');
ylabel('Error');
title('Error Signal');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -