Run the functions for the lab exercise.
> source("lab5.r")
Try the lower_ones function.
> lower_ones(5)
[,1] [,2] [,3] [,4] [,5]
[1,] 1 0 0 0 0
[2,] 1 1 0 0 0
[3,] 1 1 1 0 0
[4,] 1 1 1 1 0
[5,] 1 1 1 1 1
Try the matrix_from_list function.
> matrix_from_list (4, 5, list (c(2,3,22), c(1,5,19), c(4,2,37)))
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 19
[2,] 0 0 22 0 0
[3,] 0 0 0 0 0
[4,] 0 37 0 0 0
Plot temperatures after 50 and 1000 iterations of heat flow.
> M <- initial_temperatures(30,30)
>
> for (k in 1:50) M <- heat_flow(M)
> persp(M,phi=30,theta=-10)
> contour(M)
> for (k in 1:950) M <- heat_flow(M)
> persp(M,phi=30,theta=-10)
> contour(M)