diff options
Diffstat (limited to 'matlab_helper_files/map2dat.m')
-rw-r--r-- | matlab_helper_files/map2dat.m | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/matlab_helper_files/map2dat.m b/matlab_helper_files/map2dat.m new file mode 100644 index 0000000..4f4ca52 --- /dev/null +++ b/matlab_helper_files/map2dat.m @@ -0,0 +1,33 @@ +function map2dat(outfile, x,y,z, xskip, yskip) +% saves 3D data in suitable way to be drawn by gnuplot +% x,y - vectors of x,y values +% z map of z values as used by Octave/Matlab +% xskip, yskip - skip paprameters +% only every, xskip, yskip point will be written + + + +Nx=length(x); +Ny=length(y); +Nxs=ceil(Nx/xskip); +Nys=ceil(Ny/yskip); +points=zeros(1,3*Nxs*Nys); +%points=[]; +tic; +for i=1:Nxs + for k=1:Nys + %points=[points x(i*xskip) y(k*yskip) z(k*yskip,i*xskip)]; + points((i-1)*(Nys)*3+3*(k-1)+1) = x(1+(i-1)*xskip); + points((i-1)*(Nys)*3+3*(k-1)+2) = y(1+(k-1)*yskip); + points((i-1)*(Nys)*3+3*(k-1)+3) = z(1+(k-1)*yskip,1+(i-1)*xskip); + end +end +disp('=== points formation complete ==='); +toc +tic; +%points +fd = fopen(outfile, "wt"); +fprintf (fd, "%g %g %g\n", points); +fclose(fd); +disp('=== points saving complete ==='); +toc; |