Prev: end points of a line
Next: polyarea help
From: Fivos on 1 Jul 2010 05:03 "Andrew McGillis" <amcgillisREMOVE(a)rogers.com> wrote in message <gkgk19$14g$1(a)fred.mathworks.com>... > "Gyusok " <gyusok(a)gmail.com> wrote in message <gkgbbq$r0o$1(a)fred.mathworks.com>... > > Hello, > > > > I am Matlab user with little experience. Probably this question is pretty easy for most of you, but I did not find any solution: > > I have a matrix with n-rows and three columns that represent the 3-dimensional kartesian coordinates of n-surface points obtained by loading a data file. > > These points I want to visualise as a surface, not just as points in a Figure. > > > > The Matrix is as follows: > > x y z > > Points = 1.2360 25.4359 38.3812 > > 0.9510 25.4896 36.9742 > > 0.6072 25.5178 35.5796 > > 0.0600 25.5160 33.7439 > > -0.4068 25.4894 32.3855 > > -0.9237 25.4400 31.0457 > > -1.6916 25.3376 29.2938 > > 1.2063 24.6046 37.1182 > > 0.9283 24.7229 35.8329 > > 0.5895 24.8152 34.5606 > > 0.0527 24.9007 32.8865 > > -0.4075 24.9381 31.6487 > > -0.9146 24.9552 30.4301 > > etc.... > > > > I want to plot the information in the matrix as a surface and not as it is possible using the plot3 command as points. I tried to use the mesh and surf command but did not succed to display a decent visualisation in a figure window. > > > > > > Thank you very much for your help. > > > > Gyusok > > If your data is not evenly spaced in x and y, you will need to make a mesh, then interpolate it to the mesh using griddata (or JE's gridfit) > > You might try: > % copy-paste from here down------------------ > > x=Points(:,1); > y=Points(:,2); > z=Points(:,3); > > dx=1; > dy=1; > > x_edge=[floor(min(x)):dx:ceil(max(x))]; > y_edge=[floor(min(y)):dy:ceil(max(y))]; > [X,Y]=meshgrid(x_edge,y_edge); > Z=griddata(x,y,z,X,Y); > % The following line of code is if you use JE's gridfit: > % Z=gridfit(x,y,z,x_edge,y_edge); > > %NOW surf and mesh will work... > > surf(X,Y,Z) > %mesh(X,Y,Z) > > %End of code to be copied----------------------- > > > Cheers, > Andrew Thanks a ton , this post helped me a lot ! Also note that instead of Z=griddata(x,y,z,X,Y); you can use F = TriScatteredInterp(x,y,z); Z= F(X,Y); which is better according to http://blogs.mathworks.com/loren/2009/07/22/computational-geometry-in-matlab-r2009a-part-ii/
|
Pages: 1 Prev: end points of a line Next: polyarea help |