ttsf.m
来自「Matlab程序用作混沌时间序列的预测。」· M 代码 · 共 46 行
M
46 行
% TO RUN
% ---------
% mydata = mgts(3000);
% n = 0;
% RMSE = ttsf(mydata)
function RMSE = ttsf(mydata) % Test Time Series Forecasting
global TR;
TR = 0;
% Plot My Data
t=1001:2000;
subplot(3, 1, 1);
plot(t, mydata)
h = legend('My Data', 1);
%---------------------------------------------
% Plot Fuzzy Sets
x = 0:0.01:2;
fs = fsloc(x);
subplot(3, 1, 2);
plot(x, fs)
h = legend('Fuzzy Sets', 1);
%---------------------------------------------
% Invoking Forecasting
L=400; % No. of Test Points
for np = 1:L
fc(np+505) = st1(mydata, np);
end
% ---------------------------------------------
% Plot Forecasted & Test Data Simultaneously
t = 505:505+L;
tsd = mydata(505:505+L);
fcd = fc(505:505+L);
subplot(3, 1, 3);
plot(t, fcd, '-k', t, tsd, '-.b')
h = legend('Forecast','Test Data',2);
% --------------------------------------------
% Calculation of Root Mean Square Value
ErrS = 0;
for t=1:L
ErrS = ErrS + (tsd(t) - fcd(t))^2;
end
RMSE = sqrt(ErrS/L);
% --------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?