0
votes

How would I do this in R? The prompt is:

Generate 1000 2⇥2 matrices whose elements are random numbers(not all integers) that range between 10 and 10.2.For each matrix compute the eigenvalues. Plot each eigenvalue

So far I've done M=matrix(runif(4, min=-10, max=10), ncol=2, nrow=-10)

and I don't really know where to go from here.

1
this looks like homework. Homework is allowed on SO, but you should explain what you've tried to do so far and where you got stuck -- don't just cut-and-paste a homework assignment please ... - Ben Bolker
My bad, sorry about that. But what I first tried doing was M=matrix(runif(4), ncol=2, nrow=2) but I didn't know where to go from there. - Tiffany Nguyen

1 Answers

0
votes

Not sure if you want this as a list, but if you do:

mats <- lapply(1:1000, function(x) matrix(runif(4), ncol = 2, nrow = 2))
eigens <- lapply(mats, eigen)