The matrix I used was 3 columns with x, y, and z values. The correct format to enter into persp() or wireframe() is one with only the z values in the body of the matrix, x and y values are only the row and column labels. For example:
if I had:
x y z
[1,] 0 0 17437
[2,] 0 1 3627
[3,] 0 2 2329
[4,] 1 0 2851
[5,] 1 1 1343
[6,] 1 2 967
[7,] 2 0 1681
[8,] 2 1 906
[9,] 2 2 689
[10,] 3 0 1241
[11,] 3 1 733
[12,] 3 2 582
I needed to change it to:
0 1 2
0 1343 967 794
1 906 689 591
2 733 582 505
3 630 509 438
where row names correspond to x values and column names correspond to y values. To enter this into the commands just type: persp(MatrixName) wireframe(MatrixName)