From help-octave-request at bevo dot che dot wisc dot edu Thu Feb 1 10:44:44 2001 Subject: Re: plotting in 3D From: Ben Sapp To: courtois at ensia dot inra dot fr, help-octave@bevo.che.wisc.edu Date: Thu, 01 Feb 2001 09:44:43 -0700 courtois at ensia dot inra dot fr wrote: > > On 1 Feb, Etienne Grossmann wrote: > > > > Hello, > > > > From: courtois at ensia dot inra dot fr > > # Hi > > # > > # I don't understand how to plot in 3d a matrix (30 x 3). I read > > # sombrero.m but in my case the mesh is partial, and the "gset > > # parametrics" is ununderstandable. > > # > > # any help ? > > > > What about : > > > > octave:361> [x, y] = meshgrid (linspace (-10,10,30),linspace (-10,10,30)); > > octave:362> z = sin (x) + y.^2/100; > > octave:363> mesh (x, y, z) > > the problem is that I have already x y z in a matrix. So I don't have a > complete mesh. I have difficulties to explain myself in english. In fact > x y z (in matrix A) is partial experimental design with results in > column z Do I understand correctly that you actually want a 3-d trajectory and not a mesh? A mesh is only good for a surface. If that is the case then I think I have solved this exact problem a few months back. The function I wrote does no type checking what so ever. I wrote it because I needed to plot the trajectory of a differential equation. You may need to transpose your matrix if the dimensions don't agree with what the function expects. It expects x to be in the first column, y in the second column, z in the third column. The Function: ------------------------------------------------------ function plot3d(x) name = tmpnam(); [id,msg] = fopen(name,"w"); for i = 1:(size(x)(1)) fprintf(id, "%f %f %f\n",x(i,1),x(i,2),x(i,3)); endfor fflush(name); cmd = sprintf("gsplot \"%s\"\n",name); eval(cmd); fclose(name); endfunction -------------------------------------------------------- Good luck. -- Ben Sapp Los Alamos National Laboratory email: Phone: (505)667-3277 Fax: (505)665-7920 URL: http://www.neutrino.lanl.gov/ -- ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------