From: 德馬堤 <d00...@nt...> - 2024-10-13 11:36:59
|
Nice attempt! A more general version is M:matrix([1,2,2],[4,5,3],[7,8,4],[10,11,5])$ f(x, y) := float('M[round(x), round(y)])$ plot3d (f(x,y), [x,1,length(M)], [y,1,length(M[1])], [grid,length(M)-1,length(M[1])-1])$ Note that the matrix M is not necessarily a square matrix. Let's say the vectors X and Y have been used to generate the data stored in M. They are the actual positions on the x and y axes where the data points are located. Above version locates them always at 1, 2, 3, etc., but this is not a general case. Also, I would prefer the color of the surface to change smoothly with the surface height. Using round(x) and round(y) is nonsmooth. |