【发布时间】:2020-05-09 16:12:26
【问题描述】:
以下代码在R中运行时,会弹出错误信息:
“Xt[i, ]
感谢您的帮助。
X=matrix(rnorm(6),100,6)
n = nrow(X)
F = diag(1,6,6); F[1,4] = F[2,5] = F[3,6] = 1
#create process & measurement noises (standard deviation)
W = diag(rnorm(1,0,0.01),6,6)
V = diag(rnorm(1,0,0.02),6,6)
#create and init Xt and Yt matrices
Xt = matrix(NA, nrow=n+1, ncol=6)
Yt = matrix(NA, nrow=n, ncol=6)
Xt[1,] = X[1,]
#test:
F * Xt[1,] + V #this is fine!!!
#before entering the loop:
for (i in 2:3)
{
Xt[i,] = F * Xt[i-1,] + V #BUT this is not!!!
Yt[i,] = Xt[i,] + W
}
【问题讨论】: