############################################### # scriptfile: usr_surface_3d_1.lsf # # description: This file creates a surface text # file for an import primitive. # # Copyright 2007, Lumerical Solutions, Inc. ############################################### # generate a surface nx = 50; ny = 40; x = linspace(-6,6,nx); y = linspace(-5,5,ny); X = meshgridx(x,y); Y = meshgridy(x,y); Z = exp(-(X^2+Y^2)/6^2) * sin(sqrt(X^2+Y^2)); # choose a filename and delete file if it exists filename = "usr_surface_3d_1.txt"; rm(filename); # write the header to file write(filename,"0 " + num2str(nx-1) + " " + num2str(ny-1)); # write the x data to file write(filename,num2str(transpose(x))); # write the remaining data to file for(j=1:ny) { outstring = num2str(y(j)); for(i=1:nx) { outstring = outstring + " " + num2str(Z(i,j)); } write(filename,outstring); }