主要内容

预报

Forecast identified model output

Description

example

yf=预测(sys,PastData,K)预报s the output of an identified time series modelsys,Ksteps into the future using past measured data,PastData

预报在未来的时间范围内执行预测,超出了最后一个测量数据的瞬间。相反,预测command predicts the response of an identified model over the time span of measured data. Use预测to determine if the predicted result matches the observed response of an estimated model. Ifsysis a good prediction model, consider using it with预报

example

yf=预测(sys,PastData,K,未来注射)使用输入的未来值,未来注射,以预测使用输入通道的识别模型的响应。

example

yf=预测(___,opts)用途the option set,opts, to specify additional forecast options. Useoptswith any of the previous input argument combinations.

example

[yf,x0,sysf] =预测(___)also returns the estimated values for initial states,x0, 和a forecasting model,sysf, 和can include any of the previous input argument combinations.

example

[yf,x0,sysf,YF_SD,x,x_sd] =预测(___)还返回输出的估计标准偏差,YF_SD,状态轨迹,x, 和standard deviation of the trajectory,x_sd。与任何先前的输入参数组合一起使用。

example

预报(sys,PastData,K,___)绘制预测的输出。与任何先前的输入参数组合一起使用。

To change display options, right-click the plot to access the context menu. For example, to view the estimated standard deviation of the forecasted output, selectConfidence Region从the context menu. For more details about the menu, see尖端

example

预报(sys,Linespec,PastData,K,___)用途Linespec指定行类型,标记符号和颜色。

预测(sys1,...,sysn,PastData,K,___)情节的预测输出多个identified models.预报自动选择颜色和线条样式。

预报(sys1,Linespec1,...,sysN,LinespecN,PastData,K,___)使用为每个系统指定的行类型,标记符号和颜色。

Examples

全部收缩

Forecast the values of a sinusoidal signal using an AR model.

生成和绘图数据。

data = iddata(sin(0.1*[1:100])',[]);图(数据)

图包含一个轴对象。The axes object with title y1 contains an object of type line. This object represents data.

Fit an AR model to the sine wave.

sys = ar(data,2);

在给定时间范围内预测未来的值。

k = 100;p =预测(sys,data,k);

Kspecifies the forecasting time horizon as 100 samples.pis the forecasted model response.

Plot the forecasted data.

图(数据,'b',p,'r'), legend(“测量”,“预测”)

图包含一个轴对象。带标题Y1的轴对象包含2个类型行的对象。这些对象表示测量,预测。

Alternatively, plot the forecasted output using the syntax预测(系统,数据,k)

获取过去的数据,并确定时间序列模型。

loadIDDATA9z9past_data = z9.OutputData(1:50); model = ar(z9,4);

z9is aniddata仅包含测量输出的对象。

modelis aniDpoly时间序列模型。

Specify initial conditions for forecasting.

opt =预测('初始条件','e');

在给定时间范围内绘制预测的系统响应。

k = 100;预测(型号,past_data,k,opt);传奇('Measured',“预测”)

图包含一个轴对象。轴对象包含2个类型行的对象。These objects represent Measured (y1), Forecasted.

获取过去的数据,并确定时间序列模型。

loadIDDATA9z9past_data = z9.OutputData(1:50); model = ar(z9,4);

z9is aniddata仅包含测量输出的对象。

将给定时间范围的预测系统响应绘制为红色虚线。

k = 100;预测(模型,'r--',past_data,K);

图包含一个轴对象。轴对象包含2个类型行的对象。这些对象代表过去的数据(Y1),模型。

The plot also displays the past data by default. To change display options, right-click the plot to access the context menu. For example, to view the estimated standard deviation of the forecasted output, selectConfidenceRegion从the context menu. To specify number of standard deviations to plot, double-click the plot and open the Property Editor dialog box. In the dialog box, in theOptions选项卡,指定标准偏差的数量识别模型的置信区。The default value is1standard deviation.

Obtain past data, future inputs, and an identified linear model.

loadIDDATA1z1z1 = iddata(cumsum(z1.y),cumsum(z1.u),z1.Ts,“样本间”,'foh');past_data = z1(1:100); future_inputs = z1.u(101:end); sys = polyest(z1,[2 2 2 0 0 1],'IntegrateNoise',true);

z1is aniddata包含集成数据的对象。sysis aniDpoly模型。past_datacontains the first 100 data points ofz1

future_inputscontains the last 200 data points ofz1

在给定时间范围和未来输入中,预测系统对未来的响应。

k = 200;[yf,x0,sysf,yf_sd,x,x_sd] =预测(sys,past_data,k,future_inputs);

yfis the forecasted model response, andYF_SDis the standard deviation of the output.x0is the estimated value for initial states, andsysf是预测状态空间模型。还返回的是状态轨迹,x, 和standard deviation of the trajectory,x_sd

绘制预测的响应。

upperbound = iddata(yf.outputdata+3*yf_sd,[],yf.ts,'Tstart',yf.tstart);lowerbound = iddata(yf.outputdata-3*yf_sd,[],yf.ts,'Tstart',yf.tstart);plot(past_data(::,:,[]),yf(::,, []),上行,'k--',LowerBound,'k--') 传奇({'Measured',“预测”,'3 sd uncertainty'},,'地点','best')

图包含一个轴对象。带标题Y1的轴对象包含4个类型行的对象。这些对象代表测量,预测的3 SD不确定性,下部。

Plot the state trajectory.

t = z1.smplingInstants(101:end);子图(3,1,1)图(t,x(:,1),t,x(:,1)+3*x_sd(:,1),'k--',t,x(:,1)-3*x_sd(:,1),,'k--') 标题(“X_1”)子图(3,1,2)图(t,x(:2),t,x(:,2)+3*x_sd(:,2),,'k--',t, x(:,2)-3*x_sd(:,2),'k--') 标题('X_2')子图(3,1,3)图(t,x(:3),t,x(:,3)+3*x_sd(:,3),,,'k--',t,x(:,3)-3*x_sd(:,3),,'k--') 标题('x_3')

图包含3个轴对象。轴对象1带标题x索引1基线包含3个类型行的对象。轴对象2带标题x索引2基线包含3个类型行的对象。轴对象3带标题x索引3基线包含3个类型行的对象。

由于未来输入的规范,响应不确定性不会在预测时间段内增长。

Load data.

负载(fullfile(Matlabroot,,'工具箱','ident','iddemos','数据','predprey2data')); z = iddata(y,[],0.1); set(z,'Tstart',0,“ outputunit”,{'Population (in thousands)',。。。'Population (in thousands)'},,'TimeUnit','Years');

zis a two output time-series data set (no inputs) from a 1-predator 1-prey population. The population exhibits a decline in predator population due to crowding. The data set contains 201 data samples covering 20 years of evolution.

捕食者的变化(y1) and prey (y2) population can be represented as:

y 1 ( t ) = p 1 * y 1 ( t - 1 ) + p 2 * y 1 ( t - 1 ) * y 2 ( t - 1 )

y 2 ( t ) = p 3 * y 2 ( t - 1 ) - p 4 * y 1 ( t - 1 ) * y 2 ( t - 1 ) - p 5 * y 2 ( t - 1 ) 2

捕食者和猎物种群中的非线性可以使用带有自定义回归器的非线性ARX模型拟合。

Use part of the data as past data.

past_data = z(1:100);

Specify the standard regressors.

na = [1 0;0 1];nb = [];nk = [];

指定自定义回归器。

c = {{{'y1(t-1)*y2(t-1)'};{'y1(t-1)*y2(t-1)','y2(t-1)^2'}};

Estimate a nonlinear ARX model usingpast_dataas estimation data.

sys = nlarx(过去_data,[na nb nk],'iDwaveletnetwork','CustomRegressors',C);

Compare the simulated output ofsyswith measured data to ensure it is a good fit.

compare(past_data,sys);

图包含2个轴对象。轴对象1包含2个类型行的对象。这些对象代表过去的\ _data(y1),系统:88.92%。轴对象2包含2个类型行的对象。这些对象代表过去的\ _data(y2),SYS:86.35%。

绘制预测的输出sys

预测(sys,past_data,101);传奇('Measured',“预测”);

图包含2个轴对象。轴对象1包含2个类型行的对象。这些对象表示测量(Y1),系统。轴对象2包含2个类型行的对象。这些对象表示测量(Y2),预测。

获取过去的数据,未来输入和确定的线性模型。

loadiddata3z3past_data = z3(1:100); future_inputs = z3.u(101:end); sys = polyest(z3,[2 2 2 0 0 1]);

在给定时间范围和未来输入中,预测系统对未来的响应。

k = size(future_inputs,1);[yf,x0,sysf] =预测(sys,past_data,k,future_inputs);

yfis the forecasted model response,x0is the estimated value for initial states, andsysf是预测状态空间模型。

使用输入模拟预测状态空间模型,future_inputs, 和initial conditions,x0

opt = simOptions;opt.InitialCondition = x0;ys = sim(sysf,future_inputs(1:k),opt);

Plot the forecasted and simulated outputs.

t = yf.smplingInstants;图(t,yf.outputdata,'b',t,ys,'.r');传奇('Forecasted Output','Simulated Output')

图包含一个轴对象。轴对象包含2个类型行的对象。这些对象表示预测的输出,模拟输出。

Simulation of forecasting model,sysf, with inputs,future_inputs, 和initial conditions,x0, yields the forecasted output,yf

Input Arguments

全部收缩

确定的模型将被预测,并指定为以下一个:

如果a model is unavailable, estimatesysPastData使用commands such asar,arx,Armax,Nlarx, 和SST

Past input-output time-domain data, specified as one of the following:

  • iddata对象 - 使用观察到的输入和输出信号创建一个iddata目的。For time-series data (no inputs), specify as aniddataobject with no inputsiddata(输出,[])

  • Matrix of doubles — For discrete-time models only. Specify as anN-经过-纽约时间序列数据的矩阵。这里,N是观察的数量和纽约是输出数。

    For models withnuinputs, specifyPastData作为一个N-经过-(纽约+nu) matrix.

预测的时间范围,指定为正整数。输出,yf, is calculatedK进入未来的一步,使预测时间范围是Ts*K

未来输入值,指定为以下一个:

  • []— Future input values are assumed to be zero, or equal to input offset levels (if they are specified inopts)。对于时间序列模型,指定为[]

  • iddataobject — Specify as aniddata没有输出的对象。

  • K-经过-nu双打矩阵 -Kis the forecast horizon, andnuis the number of inputs.

    如果you have data from multiple experiments, you can specify a cell array of matrices, one for each experiment inPastData

预测选项,指定为预测选项集。

线样式,标记和颜色, specified as a character vector. For example,'b'或者'B+:'

有关配置的更多信息Linespec, see the Linespec argument ofplot

Output Arguments

全部收缩

Forecasted response, returned as aniddata目的。yfis the forecasted response at times after the last sample time inPastDatayf包含时间间隔的数据t0+(n+1:n+k)*t1, whereT0 = PastData.Tstartt1 = pastdata.tsN是样本中的数量PastData

Estimated initial states at the start of forecasting, returned as a column vector of size equal to the number of states. Usex0with the forecasting modelsysfto reproduce the result of forecasting by pure simulation.

如果PastData是多种经验,x0是大小的单元格数NE, whereNE是实验的数量。

什么时候sysis not a state-space model (idss,idgrey, 或者艾德格里), the definition of states depends on ifsysis linear or nonlinear:

  • Linear model (iDpoly,IDPROC,idtf) -sysis converted to a discrete-time state-space model, andx0is returned as the states of the converted model at a time-point beyond the last data inPastData

    如果转换systoidssis not possible,x0被返回空。例如,如果sys是具有不可还原内部延迟的MIMO连续时间模型。

  • 非线性模型(idnlhw或者idnlarx) — For a definition of the states ofidnlarxidnlhw模型,请参阅Definition of idnlarx States, 和Definition of idnlhw States

预测模型,返回以下一个:

  • Discrete-timeidss— Ifsysis a discrete-timeidssmodel,sysf是相同的sys。如果sys是不是状态空间模型的线性模型(iDpoly,IDPROC,idtf),或是连续的状态空间模型(idss,idgrey),sysis converted to a discrete-timeidss模型。转换后的模型返回sysf

  • idnlarx,idnlhw, 或者艾德格里— Ifsysis a nonlinear model,sysf是相同的sys

  • 模型的单元格数 - 如果PastDatais multiexperiment,sysfis an array ofNEmodels, whereNE是实验的数量。

Simulation ofsysf使用sim, with inputs,未来注射, 和initial conditions,x0, yieldsyfas the output. For time-series models,未来注射是空的。

Estimated standard deviations of forecasted response, returned as aK-经过-纽约矩阵,哪里Kis the forecast horizon, and纽约是输出数。该软件通过考虑模型参数协方差,初始状态协方差和加性噪声协方差来计算标准偏差。加性噪声协方差存储在NoiseVariance模型的属性。

如果PastDatais multiexperiment,YF_SD是大小的单元格数NE, whereNE是实验的数量。

YF_SD如果是空的sys是非线性arx(idnlarx)或Hammerstein-Wiener模型(idnlhw)。YF_SD如果是空的sys不包含参数协方差信息,也就是说GetCov(sys)是空的。For more information, seeGetCov

预测状态轨迹,返回K-经过-nx矩阵,哪里K,预测范围和nx是状态数。xare the states of the forecasting model.

如果PastDatais multiexperiment,x是大小的单元格数NE, whereNE是实验的数量。

如果sys是线性模型以外的线性模型(不是状态空间模型(不是)idss或者idgrey),然后将其转换为离散的状态空间模型,并计算转换后的模型的状态。如果转换systoidssis not possible,x被返回空。例如,如果sys是具有不可还原内部延迟的MIMO连续时间模型。

x如果是空的sys是非线性arx(idnlarx)或Hammerstein-Wiener模型(idnlhw)。

预测状态的估计标准偏差x, returned as aK-经过-NS矩阵,哪里K,预测范围和NS是状态数。该软件通过考虑模型参数协方差,初始状态协方差和加性噪声协方差来计算标准偏差。加性噪声协方差存储在NoiseVariance模型的属性。

如果PastDatais multiexperiment,x_sd是大小的单元格数NE, whereNE是实验的数量。

如果sys是线性模型以外的线性模型(不是状态空间模型(不是)idss或者idgrey), then it is converted to a discrete-time state-space model, and the states and standard deviations of the converted model are calculated. If conversion ofsystoidssis not possible,x_sd被返回空。例如,如果sys是具有不可还原内部延迟的MIMO连续时间模型。

x_sd如果是空的sys是非线性arx(idnlarx)或Hammerstein-Wiener模型(idnlhw)。

尖端

  • 右键单击图将打开上下文菜单,您可以在其中访问以下选项:

    • 系统— Select systems to view forecasted output. By default, the forecasted output of all systems is plotted.

    • 数据实验- 仅用于多实验数据。从不同实验的数据之间切换。

    • 特征- 查看以下数据特征:

      • Peak Value- 查看数据的峰值。

      • Mean Value- 查看数据的平均值。

      • Confidence Region— View the estimated standard deviation of the forecasted output. To specify number of standard deviations to plot, double-click the plot and open the Property Editor dialog box. Specify the number of standard deviations in theOptions选项卡,in识别模型的置信区。The default value is1standard deviation.

        The confidence region is not generated for nonlinear ARX and Hammerstein-Wiener models and models that do not contain parameter covariance information.

    • Show Past Data— Plot the past output data used for forecasting. By default, the past output data is plotted.

    • I/O分组— For datasets containing more than one input or output channel. Select grouping of input and output channels on the plot.

      • 没有任何— Plot input-output channels in their own separate axes.

      • 全部— Group all input channels together and all output channels together.

    • i/o选择器— For datasets containing more than one input or output channel. Select a subset of the input and output channels to plot. By default, all output channels are plotted.

    • Grid— Add grids to the plot.

    • 归一化— Normalize the y-scale of all data in the plot.

    • Full View- 返回全视图。默认情况下,图将缩放到完整视图。

    • Properties— Open the Property Editor dialog box to customize plot attributes.

Version History

在R2012a中引入