我正在遵循SMD分析教程,在R中编写一个脚本,在Z方向上计算和绘制图形。当我的脚本运行时,前两个值是零,它们不应该是be...help?
#calcwork1.tcl#
n_time_steps <- 200
repeat {
dz <- 0.1
dW = dz*Fz
W <- rep(0, n_time_steps + 1)
W[1]
dW[1]
for (i in 2:n_time_steps + 1){
W[i] <- W[i - 1] + dW[i - 1]
}
if (i == 201)
break
}
dz = 0.1
Fz = the force in the z direction
W = output work calculated
dW = change in work
n_time_steps = 200发布于 2019-06-14 22:32:28
你不需要重复。假设Fz是一个常态,这是可行的:
n_time_steps <- 200
Fz=rnorm(n_time_steps)
dz <- 0.1
dW = dz*Fz
W <- rep(0, n_time_steps + 1)
W[1]
dW[1]
for (i in 2:(n_time_steps + 1)){
W[i] <- W[i - 1] + dW[i - 1]
}
plot(W[-1]~Fz)
plot(dW~W[-1])https://stackoverflow.com/questions/56599809
复制相似问题