问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

急求matlab中predict函数的正确使用

发布网友 发布时间:2022-05-02 15:37

我来回答

1个回答

热心网友 时间:2022-06-17 15:50

这是matlab给的解释,你看吧

predict
Predict output k steps ahead
Syntax
yp = predict(m,data)
[yp,x0p,mpred] = predict(m,data,k,'InitialState',init)

Description

data is the output-input data as an iddata object, and m is any idmodel or idnlmodel object. predict is meaningful only for time-domain data.

The argument k indicates that the k step-ahead prediction of y according to the model m is computed. In the calculation of yp(t), the model can use outputs up to time

t–k: y(s), s = t–k, t–k–1,...

and inputs up to the current time t. The default value of k is 1.

The output yp is an iddata object containing the predicted values as OutputData.

x0p is the used (estimated) initial state vector. For multiexperiment data, x0p is a matrix, whose columns contain the initial states for each experiment.

The output argument mpred contains the k step-ahead predictor. This is given as a cell array, whose kth entry is an idpoly model for the predictor of output number k. Note that these predictor models have as input both input and output signals in the data set. The channel names indicate how the predictor model and the data fit together.

init determines how to deal with the initial state:

init ='e(stimate)': The initial state is set to a value that minimizes the norm of the prediction error associated with the model and the data.

init = 'd(elayexpand)': Same as 'estimate', but for a model with nonzero InputDelay, the delays are first converted to explicit model delays (using inpd2nk) so that they are contained in x0p.

init = 'z(ero)' sets the initial state to zero.

init = 'm(odel)' uses the model's internally stored initial state.

init = x0, where x0 is a column vector of appropriate dimension, uses that value as initial state. For multiexperiment data, x0 can be a matrix whose columns give different initial states for each experiment. For a continuous-time model m, x0 is the initial state for this model. Any modifications of the initial state that sampling might require are automatically handled. If m has a non-zero InputDelay, and you need to access the values of the inputs ring this delay, you must first apply inpd2nk(m). When m is a continuous-time model, it must first be sampled before inpd2nk can be applied.

If init is not specified for linear models, its value is determined, as follows:

If m.InitialState is 'Estimate', 'Backcast', and 'Auto', init = 'Estimate'.

If m.InitialState is 'Zero', init = 'zero'.

If m.InitialState is 'Model' or 'Fixed', init = 'model'. For idss, idproc, and idgrey models, init corresponds to the m.x0 values. For other linear models, init = 'zero'.

If init is not specified for idnlgrey models, init = 'Model' is the default. The values and their estimation behavior are inherited from m.InitialStates.

If init is not specified for idnlarx models, init = 'Estimate' is the default. This corresponds to the first few samples of predicted outputs exactly matching the first few output samples in the data set.

If init is not specified for idnlhw models, init = 'Estimate' is the default. This computes initial states by minimizing the prediction errors over the available data range.

An important use of predict is to evaluate a model's properties in the mid-frequency range. Simulation with sim (which conceptually corresponds to k = inf) can lead to levels that drift apart, since the low-frequency behavior is emphasized. One step-ahead prediction is not a powerful test of the model's properties, since the high-frequency behavior is stressed. The trivial predictor can give good predictions in case the sampling of the data is fast.

Another important use of predict is to evaluate time-series models. The natural way of studying a time-series model's ability to reproce observations is to compare its k step-ahead predictions with actual data.

Note that for output-error models, there is no difference between the k step-ahead predictions and the simulated output, since, by definition, output-error models only use past inputs to predict future outputs.
Algorithms

The model is evaluated in state-space form, and the state equations are simulated k steps ahead with initial value , where is the Kalman filter state estimate.
Examples

Simulate a time series, estimate a model based on the first half of the data, and evaluate the four step-ahead predictions on the second half.
m0 = idpoly([1 -0.99],[],[1 -1 0.2]);
e = iddata([],randn(400,1));
y = sim(m0,e);
m = armax(y(1:200),[1 2]);
yp = predict(m,y,4);
plot(y(201:400),yp(201:400))

Note that the last two commands are also achieved by
compare(y,m,4,201:400);

See Also

compare | pe | sim | sims

clc, clear

a=[ ];
a=a'; a=a(:); a=a'; %把原始数据按照时间顺序展开成一个行向量
Rt=tiedrank(a) %求原始时间序列的秩
n=length(a); t=1:n;
Qs=1-6/(n*(n^2-1))*sum((t-Rt).^2) %计算Qs的值
t=Qs*sqrt(n-2)/sqrt(1-Qs^2) %计算T统计量的值
t_0=tinv(0.975,n-2) %计算上alpha/2分位数
b=diff(a) %求原始时间序列的一阶差分
m=ar(b,2,'ls') %利用最小二乘法估计模型的参数
bhat=predict(m,[b'; 0],1) %1步预测,样本数据必须为列向量,要预测1个值,b后要加1个任意数,1步预测数据使用到t-1步的数据
ahat=[a(1),a+bhat{1}'] %求原始数据的预测值,并计算t=15的预测值
delta=abs((ahat(1:end-1)-a)./a) %计算原始数据预测的相对误差追问一开始就看过了。。按他说的做结果有些问题。。。您能不能自己写个实际的程序呢

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
通达信主力指标公式汇总(2023版附源码) 有什么类似地下城与勇士的手机游戏 有没有类似于DNF的游戏 苹果手机类似地下城的游戏 有什么类似地下城与勇士的手机游戏 我的系统是WIN732,为什么玩不了光晕2,一点开就弹一个对话框出来说:无法... 玩诛仙电脑配置诛仙3要求电脑配置 ...永磁为什么要跌啊?东方财富金力永磁股吧?金力永磁股票最初..._百度... 怎么找回注销的微信号 如果把手机号码和微信号同时销户后期还能找回微信号吗? 仓储与库存有什么区别? 仓位和库位的区别 小学生制作卡片勤俭节约 封面设计纸张什么意思? 请问大家现在什么类型的企业用corelDRAW最多啊 210X285mm一款画册 封面用250铜版纸,内页157克铜版纸,(含封面和内页一共50P) 干红枣怎么辨别宝塔泡糖精的枣怎么辨别 红枣太甜是不是泡了糖精 有些干枣是已经提过枣汁的,怎么区分枣有没有提取过枣汁 干红枣会加有糖精吗?有的话如何鉴别? 画册封面如何排版用PS的 内容是A4纸那么大,封面用PS,在PS里设计成A3吗 干货红枣太甜是不是糖精泡过? 干红枣泡了甜蜜素的鉴别 红枣泡糖精怎么判断? 梦见过世的母亲从棺材活过来并说了自己某些地方做得不好 怎样分辨注糖精干红枣 梦见自巳的母亲死了从棺材坐起棺材夹住了手? 梦见去世的妈妈在山上入土时从棺材里坐起来那? 今年最热门的书 最火的网络小说排行, 07年畅销书排行 最近最畅销的小说是什么? MATLAB predict函数的结果 请问predict函数怎么用啊。 predict(m,n,step)里的STEP是什么 matlab注释:Predict labels for testing images using NN中NN是啥意思 用matlab做决策树分类,分类的类别应该怎样在matlab中设置呢 MATLAB系统辨识工具箱所得到模型的初始状态问题 求BP网络预测的matlab代码 svmpredict怎么在matlab中使用 急求,通过matlab建立决策树怎么提取分类规则 matlab中怎样反归一化,我是个菜鸟,请大神们帮我改改,虽然没有悬赏了,呜呜··· 求大神解释一下下面的MATLAB目标跟踪程序,是matlab自带的例子 matlab智能算法30个案例分析中第29哥案例的代码为什么一直出错 交强险不到期能重复买不 交强险没到期可以到另一个公司在购买吗 二手车交强险还没到期需重新买吗 18考研东北财经大学,世界经济学专业的就业前景怎么样? 世界经济和国际贸易哪个专业更好就业呢? 二手车交强险未到期可以换吗 如果交强险还没到期(3月到期),但年审到期(1月到期),需要购买交强险吗? 前辈们中央财经大学世界经济专业就业怎么样