I am unable to append to a numeric vector in R
y1 <- c()
euler <- function(f, y0, a, b, h)
{
t <- a
y <- y0
while(t < b | isTRUE(all.equal(t, b))){
t <- t + h
y <- y + h*f(t, y)
print(y)
y1 <- c(y1, y)
}
}
System_model <- function(y, t)
return (y+t)
euler(System_model, 1, 0, 1, 0.1)
Expected: y1 has some values
Actual: y1 is empty