# Sample 2-d plot # You can run this by typing at the prompt: octave -q 2dplot.m # Set some basic parameters, including the name of the # output data file. outfile = "2dplot.dat"; global a = 1; z_vec = linspace(1, 5, 100); # "quad" is octave's integration function. You can type # "help quad" and "help quad_options" in octave for help. function r = f(x) global z; r = 2*sin(x).*sqrt((z + sin(x))); endfunction function r = F() global a; r = quad("f", -pi/2, a); endfunction # The main loop. points = []; global z; for z = z_vec points = [points z sin(z)*F()/(z + sin(a))**(3/2)]; endfor # Save the data to a file and exit. The output format # is very simple (two columns) and appropriate for gnuplot. fd = fopen(outfile, "wt"); fprintf(fd, "%14.6f %14.6f\n", points); fclose(fd); disp("Done!");