% DO NOT EDIT! Generated automatically by dump_demos.m function dump_plot_demos () close all more off diary diary.log try if (! exist ('annotation_01.png', 'file')) rand ('seed', 1); tic (); clf; axes ('visible', 'off'); annotation ('textbox', [.25 .9 .5 .09], 'string', ... {'Right Click on annotation objects', ... 'to customize their appearance'}, ... 'horizontalalignment', 'center', 'fitboxtotext', 'off'); annotation ('ellipse', [.2 .2 .6 .6], 'linewidth', 4) ang = pi/2:-pi/2:-pi; lab = {'N', 'W', 'S', 'E'}; x0 = 0.5; y0 = 0.5; r = 0.3; for ii = 1:4 x = r * cos (ang(ii)) + x0; y = r * sin (ang(ii)) + y0; annotation ('textarrow', [x x0], [y y0], ... 'string', lab{ii}, 'fontsize', 20); end h = annotation ('doublearrow', [x0 x0], [y0-r y0+r], ... 'head1style', 'diamond', 'head1length', 60, ... 'head2style', 'diamond', 'head2length', 60); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "annotation_01.png" ... '); tic (); print ('-dpng', 'annotation_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "annotation_01.png" already exists.\n'); end catch fprintf ('ERROR in annotation_01: %s\n', lasterr ()); err_fid = fopen ('annotation_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('annotation_02.png', 'file')) rand ('seed', 1); tic (); clf; axes ('visible', 'off'); plot (1:10); xlabel ('X-LABEL') ylabel ('LARGE Y-LABEL', 'fontsize', 20) title ('FIGURE LAYOUT', 'fontsize', 24) ti = get (gca, 'tightinset'); pos = get (gca, 'position'); pos(1:2) = pos(1:2) - ti(1:2); pos(3) = pos(3) + ti (1) + ti (3); pos(4) = pos(4) + ti (2) + ti (4); ht = annotation ('textbox', pos, 'string', ' Position + tighinset', ... 'fitboxtotext', 'off', 'linestyle', '--', ... 'edgecolor', 'g', 'linewidth', 3, 'color', 'g', ... 'verticalalignment', 'bottom', 'fontsize', 15); ho = annotation ('textbox', get (gca, 'outerposition'), ... 'string', ' Outerposition','fitboxtotext', 'off', ... 'linestyle', '--', 'edgecolor', 'r', ... 'linewidth', 3, 'color', 'r', ... 'verticalalignment', 'bottom', 'fontsize', 15); hi = annotation ('textbox', get (gca, 'position'), ... 'string', ' Position','fitboxtotext', 'off', ... 'linestyle', '--', 'edgecolor', 'b', ... 'linewidth', 3, 'color', 'b', ... 'verticalalignment', 'bottom', 'fontsize', 15); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "annotation_02.png" ... '); tic (); print ('-dpng', 'annotation_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "annotation_02.png" already exists.\n'); end catch fprintf ('ERROR in annotation_02: %s\n', lasterr ()); err_fid = fopen ('annotation_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('annotation_03.png', 'file')) rand ('seed', 1); tic (); clf; axes ('visible', 'off'); h = annotation ('arrow'); %% Get allowed headstyles styles = set (h, 'headstyle'); delete (h) %% Textbox for the title annotation ('textbox', [0.1 0 0.8 1], 'string', ... '"headstyle" property:', ... 'backgroundcolor', [0.7 0.7 0.7], 'fontsize', 20, ... 'fitboxtotext', 'off', 'verticalalignment', 'top', ... 'horizontalalignment', 'center'); %% Textarrows ns = numel (styles); nrows = ceil (ns/2); dy = 1/nrows; y = 1 - dy/2; jj = 1; for ii = 1:nrows annotation ('textarrow', [0.3 0.5], [y y], ... 'string', ['"' styles{jj} '"'], 'fontsize', 15, ... 'headstyle', styles{jj}, 'textcolor', 'b'); jj = jj + 1; if (jj <= ns) annotation ('textarrow', [0.7 0.5], [y y], ... 'string', ['"' styles{jj} '"'], 'fontsize', 15, ... 'headstyle', styles{jj}, 'textcolor', 'b'); jj = jj + 1; end y = y - dy; end annotation ('line', [0.5 0.5], [dy/2 1-dy/2], 'linestyle', '-.') t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "annotation_03.png" ... '); tic (); print ('-dpng', 'annotation_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "annotation_03.png" already exists.\n'); end catch fprintf ('ERROR in annotation_03: %s\n', lasterr ()); err_fid = fopen ('annotation_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('annotation_04.png', 'file')) rand ('seed', 1); tic (); clf; axes ('visible', 'off'); %% Textbox for the title annotation ('textbox', [0.1 0 0.8 1], 'string', ... 'Text arrows: text rotation', ... 'backgroundcolor', [0.7 0.7 0.7], 'fontsize', 20, ... 'fitboxtotext', 'off', 'verticalalignment', 'top', ... 'horizontalalignment', 'center'); %% Textarrows for ii = 1:10 rot = floor (rand (1) * 360 / 90) * 90; annotation ('textarrow', 0.5 + [(0.6 * (rand(1) - .5)) 0], ... 0.5 + [(0.6 * (rand(1) - .5)) 0], ... 'string', 'A text', ... 'headstyle', 'none', 'textrotation', rot); end t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "annotation_04.png" ... '); tic (); print ('-dpng', 'annotation_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "annotation_04.png" already exists.\n'); end catch fprintf ('ERROR in annotation_04: %s\n', lasterr ()); err_fid = fopen ('annotation_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('annotation_05.png', 'file')) rand ('seed', 1); tic (); clf; axes ('visible', 'off'); %% Textbox for the title annotation ('textbox', [0.1 0 0.8 1], 'string', ... 'Text arrows: text alignment', ... 'backgroundcolor', [0.7 0.7 0.7], 'fontsize', 20, ... 'fitboxtotext', 'off', 'verticalalignment', 'top', ... 'horizontalalignment', 'center'); %% Textarrows halig = {'right', 'center', 'left'}; ii = 1; for x = .3:.2:.7 annotation ('textarrow', [x .5], [.5 .9], ... 'string', {'Multiple lines', 'text'}, ... 'headstyle', 'none', 'horizontalalignment', halig{ii}); ii = ii + 1; end t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "annotation_05.png" ... '); tic (); print ('-dpng', 'annotation_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "annotation_05.png" already exists.\n'); end catch fprintf ('ERROR in annotation_05: %s\n', lasterr ()); err_fid = fopen ('annotation_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('annotation_06.png', 'file')) rand ('seed', 1); tic (); clf; axes ('visible', 'off'); x = 0:0.01:2*pi; y = sin (x); plot (x, y) %% Extrema x0 = [pi/2 3*pi/2]; y0 = [1 -1]; %% Convert axes coordinates into normalized coordinates xl = xlim (); yl = [-1.2 1.5]; ylim (yl); x0 = (x0 - xl(1)) / diff(xl); y0 = (y0 - yl(1)) / diff(yl); pos = get (gca (), 'position'); x0 = x0*pos(3) + pos(1); y0 = y0*pos(4) + pos(2); %% Textarrows for ii = 1:2 annotation ('doublearrow', [(x0(ii) - .05) (x0(ii) + .05)], ... [y0(ii) y0(ii)], 'head1style', 'vback3', ... 'head2style', 'vback3', ... 'head1width', 4, 'head2width', 4) h = annotation ('textarrow', [0.5 x0(ii)], [.85 y0(ii)], ... 'linestyle', '--', 'headstyle', 'none'); end set (h, 'string', 'Extrema', 'fontsize', 15) t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "annotation_06.png" ... '); tic (); print ('-dpng', 'annotation_06.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "annotation_06.png" already exists.\n'); end catch fprintf ('ERROR in annotation_06: %s\n', lasterr ()); err_fid = fopen ('annotation_06.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('axis_01.png', 'file')) rand ('seed', 1); tic (); clf; t = 0:0.01:2*pi; x = sin (t); subplot (221); plot (t, x); title ('normal plot'); subplot (222); plot (t, x); title ('square plot'); axis ('square'); subplot (223); plot (t, x); title ('equal plot'); axis ('equal'); subplot (224); plot (t, x); title ('normal plot again'); axis ('normal'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "axis_01.png" ... '); tic (); print ('-dpng', 'axis_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "axis_01.png" already exists.\n'); end catch fprintf ('ERROR in axis_01: %s\n', lasterr ()); err_fid = fopen ('axis_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('axis_02.png', 'file')) rand ('seed', 1); tic (); clf; t = 0:0.01:2*pi; x = sin (t); subplot (121); plot (t, x); title ('ij plot'); axis ('ij'); subplot (122); plot (t, x); title ('xy plot'); axis ('xy'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "axis_02.png" ... '); tic (); print ('-dpng', 'axis_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "axis_02.png" already exists.\n'); end catch fprintf ('ERROR in axis_02: %s\n', lasterr ()); err_fid = fopen ('axis_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('axis_03.png', 'file')) rand ('seed', 1); tic (); clf; t = 0:0.01:2*pi; x = sin (t); subplot (331); plot (t, x); title ('x tics and labels'); axis ('ticx'); subplot (332); plot (t, x); title ('y tics and labels'); axis ('ticy'); subplot (333); plot (t, x); title ('axis off'); axis ('off'); subplot (334); plot (t, x); title ('x and y tics, x labels'); axis ('labelx','tic'); subplot (335); plot (t, x); title ('x and y tics, y labels'); axis ('labely','tic'); subplot (336); plot (t, x); title ('all tics but no labels'); axis ('nolabel','tic'); subplot (337); plot (t, x); title ('x tics, no labels'); axis ('nolabel','ticx'); subplot (338); plot (t, x); title ('y tics, no labels'); axis ('nolabel','ticy'); subplot (339); plot (t, x); title ('all tics and labels'); axis ('on'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "axis_03.png" ... '); tic (); print ('-dpng', 'axis_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "axis_03.png" already exists.\n'); end catch fprintf ('ERROR in axis_03: %s\n', lasterr ()); err_fid = fopen ('axis_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('axis_04.png', 'file')) rand ('seed', 1); tic (); clf; t = 0:0.01:2*pi; x = sin (t); subplot (321); plot (t, x); title ('axes at [0 3 0 1]'); axis ([0,3,0,1]); subplot (322); plot (t, x); title ('auto'); axis ('auto'); subplot (323); plot (t, x, ';sine [0:2pi];'); hold on; plot (-3:3,-3:3, ';line (-3,-3)->(3,3);'); hold off; title ('manual'); axis ('manual'); subplot (324); plot (t, x, ';sine [0:2pi];'); title ('axes at [0 3 0 1], then autox'); axis ([0,3,0,1]); axis ('autox'); subplot (325); plot (t, x, ';sine [0:2pi];'); title ('axes at [3 6 0 1], then autoy'); axis ([3,6,0,1]); axis ('autoy'); subplot (326); plot (t, sin(t), t, -2*sin(t/2)); axis ('tight'); title ('tight'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "axis_04.png" ... '); tic (); print ('-dpng', 'axis_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "axis_04.png" already exists.\n'); end catch fprintf ('ERROR in axis_04: %s\n', lasterr ()); err_fid = fopen ('axis_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('axis_05.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.1:10; plot (x, sin(x)); axis image; title ({'image', 'equivalent to "tight" & "equal"'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "axis_05.png" ... '); tic (); print ('-dpng', 'axis_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "axis_05.png" already exists.\n'); end catch fprintf ('ERROR in axis_05: %s\n', lasterr ()); err_fid = fopen ('axis_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('axis_06.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [x,y,z] = peaks (50); x1 = max (x(:)); pcolor (x-x1, y-x1/2, z); hold on; [x,y,z] = sombrero (41); s = x1 / max (x(:)); pcolor (s*x+x1, s*y+x1/2, 5*z); axis tight; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "axis_06.png" ... '); tic (); print ('-dpng', 'axis_06.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "axis_06.png" already exists.\n'); end catch fprintf ('ERROR in axis_06: %s\n', lasterr ()); err_fid = fopen ('axis_06.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('axis_07.png', 'file')) rand ('seed', 1); tic (); clf; x = -10:10; plot (x,x, x,-x); set (gca, 'yscale', 'log'); legend ({'x >= 1', 'x <= 1'}, 'location', 'north'); title ('ylim = [1, 10]'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "axis_07.png" ... '); tic (); print ('-dpng', 'axis_07.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "axis_07.png" already exists.\n'); end catch fprintf ('ERROR in axis_07: %s\n', lasterr ()); err_fid = fopen ('axis_07.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('axis_08.png', 'file')) rand ('seed', 1); tic (); clf; loglog (1:20, '-s'); axis tight; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "axis_08.png" ... '); tic (); print ('-dpng', 'axis_08.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "axis_08.png" already exists.\n'); end catch fprintf ('ERROR in axis_08: %s\n', lasterr ()); err_fid = fopen ('axis_08.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('axis_09.png', 'file')) rand ('seed', 1); tic (); clf; x = -10:0.1:10; y = sin (x)./(1 + abs (x)) + 0.1*x - 0.4; plot (x, y); set (gca, 'xaxislocation', 'zero'); set (gca, 'yaxislocation', 'zero'); box off; title ({'no plot box', 'xaxislocation = zero, yaxislocation = zero'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "axis_09.png" ... '); tic (); print ('-dpng', 'axis_09.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "axis_09.png" already exists.\n'); end catch fprintf ('ERROR in axis_09: %s\n', lasterr ()); err_fid = fopen ('axis_09.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('axis_10.png', 'file')) rand ('seed', 1); tic (); clf; x = -10:0.1:10; y = sin (x)./(1+abs (x)) + 0.1*x - 0.4; plot (x, y); set (gca, 'xaxislocation', 'zero'); set (gca, 'yaxislocation', 'left'); box off; title ({'no plot box', 'xaxislocation = zero, yaxislocation = left'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "axis_10.png" ... '); tic (); print ('-dpng', 'axis_10.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "axis_10.png" already exists.\n'); end catch fprintf ('ERROR in axis_10: %s\n', lasterr ()); err_fid = fopen ('axis_10.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('axis_11.png', 'file')) rand ('seed', 1); tic (); clf; x = -10:0.1:10; y = sin (x)./(1+abs (x)) + 0.1*x - 0.4; plot (x, y); title ('no plot box'); set (gca, 'xaxislocation', 'zero'); set (gca, 'yaxislocation', 'right'); box off; title ({'no plot box', 'xaxislocation = zero, yaxislocation = right'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "axis_11.png" ... '); tic (); print ('-dpng', 'axis_11.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "axis_11.png" already exists.\n'); end catch fprintf ('ERROR in axis_11: %s\n', lasterr ()); err_fid = fopen ('axis_11.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('axis_12.png', 'file')) rand ('seed', 1); tic (); clf; x = -10:0.1:10; y = sin (x)./(1+abs (x)) + 0.1*x - 0.4; plot (x, y); set (gca, 'xaxislocation', 'bottom'); set (gca, 'yaxislocation', 'zero'); box off; title ({'no plot box', 'xaxislocation = bottom, yaxislocation = zero'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "axis_12.png" ... '); tic (); print ('-dpng', 'axis_12.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "axis_12.png" already exists.\n'); end catch fprintf ('ERROR in axis_12: %s\n', lasterr ()); err_fid = fopen ('axis_12.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('axis_13.png', 'file')) rand ('seed', 1); tic (); clf; x = -10:0.1:10; y = sin (x)./(1+abs (x)) + 0.1*x - 0.4; plot (x, y); set (gca, 'xaxislocation', 'top'); set (gca, 'yaxislocation', 'zero'); box off; title ({'no plot box', 'xaxislocation = top, yaxislocation = zero'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "axis_13.png" ... '); tic (); print ('-dpng', 'axis_13.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "axis_13.png" already exists.\n'); end catch fprintf ('ERROR in axis_13: %s\n', lasterr ()); err_fid = fopen ('axis_13.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('clabel_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [c, h] = contour (peaks (), -4:6); clabel (c, h, -4:2:6, 'fontsize', 12); title ('clabel() labeling every other contour'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "clabel_01.png" ... '); tic (); print ('-dpng', 'clabel_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "clabel_01.png" already exists.\n'); end catch fprintf ('ERROR in clabel_01: %s\n', lasterr ()); err_fid = fopen ('clabel_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('clabel_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [c, h] = contourf (peaks (), -7:6); clabel (c, h, -6:2:6, 'fontsize', 12); title ('clabel() labeling every other contour'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "clabel_02.png" ... '); tic (); print ('-dpng', 'clabel_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "clabel_02.png" already exists.\n'); end catch fprintf ('ERROR in clabel_02: %s\n', lasterr ()); err_fid = fopen ('clabel_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('daspect_01.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.01:4; plot (x,cos(x), x,sin(x)); axis square; daspect ([1 1 1]); title ('square plot-box with axis limits [0, 4, -2, 2]'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "daspect_01.png" ... '); tic (); print ('-dpng', 'daspect_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "daspect_01.png" already exists.\n'); end catch fprintf ('ERROR in daspect_01: %s\n', lasterr ()); err_fid = fopen ('daspect_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('daspect_02.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.01:4; plot (x,cos (x), x,sin (x)); axis ([0 4 -1 1]); daspect ([2 1 1]); title ('square plot-box with axis limits [0, 4, -1, 1]'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "daspect_02.png" ... '); tic (); print ('-dpng', 'daspect_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "daspect_02.png" already exists.\n'); end catch fprintf ('ERROR in daspect_02: %s\n', lasterr ()); err_fid = fopen ('daspect_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('daspect_03.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.01:4; plot (x,cos(x), x,sin(x)); daspect ([1 2 1]); pbaspect ([2 1 1]); title ('2x1 plot box with axis limits [0, 4, -2, 2]'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "daspect_03.png" ... '); tic (); print ('-dpng', 'daspect_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "daspect_03.png" already exists.\n'); end catch fprintf ('ERROR in daspect_03: %s\n', lasterr ()); err_fid = fopen ('daspect_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('daspect_04.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.01:4; plot (x,cos(x), x, sin(x)); axis square; set (gca, 'activepositionproperty', 'position'); daspect ([1 1 1]); title ('square plot-box with axis limits [0, 4, -2, 2]'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "daspect_04.png" ... '); tic (); print ('-dpng', 'daspect_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "daspect_04.png" already exists.\n'); end catch fprintf ('ERROR in daspect_04: %s\n', lasterr ()); err_fid = fopen ('daspect_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('daspect_05.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.01:4; plot (x,cos(x), x,sin(x)); axis ([0 4 -1 1]); set (gca, 'activepositionproperty', 'position'); daspect ([2 1 1]); title ('square plot-box with axis limits [0, 4, -1, 1]'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "daspect_05.png" ... '); tic (); print ('-dpng', 'daspect_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "daspect_05.png" already exists.\n'); end catch fprintf ('ERROR in daspect_05: %s\n', lasterr ()); err_fid = fopen ('daspect_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('datetick_01.png', 'file')) rand ('seed', 1); tic (); clf; yr = 1900:10:2000; pop = [76.094, 92.407, 106.461, 123.077 131.954, 151.868, 179.979, ... 203.984, 227.225, 249.623, 282.224]; plot (datenum (yr, 1, 1), pop); title ('US population (millions)'); xlabel ('Year'); datetick ('x', 'YYYY'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "datetick_01.png" ... '); tic (); print ('-dpng', 'datetick_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "datetick_01.png" already exists.\n'); end catch fprintf ('ERROR in datetick_01: %s\n', lasterr ()); err_fid = fopen ('datetick_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('datetick_02.png', 'file')) rand ('seed', 1); tic (); clf; yr = 1988:2:2002; yr = datenum (yr,1,1); pr = [12.1 13.3 12.6 13.1 13.3 14.1 14.4 15.2]; plot (yr, pr, '-o'); xlabel ('year'); ylabel ('average price'); ax = gca; set (ax, 'xtick', datenum (1990:5:2005,1,1)); datetick (2, 'x', 'keepticks'); set (ax, 'ytick', 12:16); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "datetick_02.png" ... '); tic (); print ('-dpng', 'datetick_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "datetick_02.png" already exists.\n'); end catch fprintf ('ERROR in datetick_02: %s\n', lasterr ()); err_fid = fopen ('datetick_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('grid_01.png', 'file')) rand ('seed', 1); tic (); clf; subplot (2,2,1); plot (1:100); grid off; title ('no grid'); subplot (2,2,2); plot (1:100); grid on; title ('grid on'); subplot (2,2,3); plot (1:100); grid off; title ('no grid'); subplot (2,2,4); plot (1:100); grid minor; title ('grid minor'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "grid_01.png" ... '); tic (); print ('-dpng', 'grid_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "grid_01.png" already exists.\n'); end catch fprintf ('ERROR in grid_01: %s\n', lasterr ()); err_fid = fopen ('grid_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('grid_02.png', 'file')) rand ('seed', 1); tic (); subplot (2,2,1); semilogy (1:100); grid off; title ('no grid'); subplot (2,2,2); semilogy (1:100); grid on; title ('grid on'); subplot (2,2,3); semilogy (1:100); grid off; title ('no grid'); subplot (2,2,4); semilogy (1:100); grid minor; title ('grid minor'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "grid_02.png" ... '); tic (); print ('-dpng', 'grid_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "grid_02.png" already exists.\n'); end catch fprintf ('ERROR in grid_02: %s\n', lasterr ()); err_fid = fopen ('grid_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_01.png', 'file')) rand ('seed', 1); tic (); clf; plot (rand (2)); title ('legend called with cellstr and string inputs for labels'); h = legend ({'foo'}, 'bar'); legend (h, 'location', 'northeastoutside'); set (h, 'fontsize', 20); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_01.png" ... '); tic (); print ('-dpng', 'legend_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_01.png" already exists.\n'); end catch fprintf ('ERROR in legend_01: %s\n', lasterr ()); err_fid = fopen ('legend_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_02.png', 'file')) rand ('seed', 1); tic (); clf; plot (rand (3)); title ('legend("show") without inputs creates default labels'); h = legend ('show'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_02.png" ... '); tic (); print ('-dpng', 'legend_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_02.png" already exists.\n'); end catch fprintf ('ERROR in legend_02: %s\n', lasterr ()); err_fid = fopen ('legend_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_03.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:1; plot (x,x,';I am Blue;', x,2*x, x,3*x,';I am Red;'); h = legend ('location', 'northeastoutside'); %% Placing legend inside should return axes to original size legend (h, 'location', 'northeast'); title ('Blue and Red keys, with Green missing'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_03.png" ... '); tic (); print ('-dpng', 'legend_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_03.png" already exists.\n'); end catch fprintf ('ERROR in legend_03: %s\n', lasterr ()); err_fid = fopen ('legend_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_04.png', 'file')) rand ('seed', 1); tic (); clf; plot (1:10, 1:10, 1:10, fliplr (1:10)); title ('incline is blue and decline is green'); legend ({'I am blue', 'I am green'}, 'location', 'east'); legend hide legend show t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_04.png" ... '); tic (); print ('-dpng', 'legend_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_04.png" already exists.\n'); end catch fprintf ('ERROR in legend_04: %s\n', lasterr ()); err_fid = fopen ('legend_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_05.png', 'file')) rand ('seed', 1); tic (); clf; plot (1:10, 1:10, 1:10, fliplr (1:10)); title ('Legend with keys in horizontal orientation'); legend ({'I am blue', 'I am green'}, ... 'location', 'east', 'orientation', 'horizontal'); legend boxoff legend boxon t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_05.png" ... '); tic (); print ('-dpng', 'legend_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_05.png" already exists.\n'); end catch fprintf ('ERROR in legend_05: %s\n', lasterr ()); err_fid = fopen ('legend_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_06.png', 'file')) rand ('seed', 1); tic (); clf; plot (1:10, 1:10, 1:10, fliplr (1:10)); title ('Legend with box off'); legend ({'I am blue', 'I am green'}, 'location', 'east'); legend boxoff t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_06.png" ... '); tic (); print ('-dpng', 'legend_06.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_06.png" already exists.\n'); end catch fprintf ('ERROR in legend_06: %s\n', lasterr ()); err_fid = fopen ('legend_06.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_07.png', 'file')) rand ('seed', 1); tic (); clf; plot (1:10, 1:10, 1:10, fliplr (1:10)); title ('Legend with text to the left of key'); legend ({'I am blue', 'I am green'}, 'location', 'east'); legend left t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_07.png" ... '); tic (); print ('-dpng', 'legend_07.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_07.png" already exists.\n'); end catch fprintf ('ERROR in legend_07: %s\n', lasterr ()); err_fid = fopen ('legend_07.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_08.png', 'file')) rand ('seed', 1); tic (); clf; plot (1:10, 1:10, 1:10, fliplr (1:10)); title ({'Use properties to place legend text to the left of key', ... 'Legend text color is magenta'}); h = legend ({'I am blue', 'I am green'}, 'location', 'east'); legend ('right'); set (h, 'textposition', 'left'); set (h, 'textcolor', [1 0 1]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_08.png" ... '); tic (); print ('-dpng', 'legend_08.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_08.png" already exists.\n'); end catch fprintf ('ERROR in legend_08: %s\n', lasterr ()); err_fid = fopen ('legend_08.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_09.png', 'file')) rand ('seed', 1); tic (); clf; plot (1:10, 1:10, 1:10, fliplr (1:10)); title ('Legend is hidden') legend ({'I am blue', 'I am green'}, 'location', 'east'); legend hide t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_09.png" ... '); tic (); print ('-dpng', 'legend_09.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_09.png" already exists.\n'); end catch fprintf ('ERROR in legend_09: %s\n', lasterr ()); err_fid = fopen ('legend_09.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_10.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:1; plot (x,x,';I am Blue;', x,2*x,';I am Green;', x,3*x,';I am Red;'); title ({'Labels are embedded in call to plot', ... 'Legend is hidden and then shown'}); legend boxon legend hide legend show t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_10.png" ... '); tic (); print ('-dpng', 'legend_10.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_10.png" already exists.\n'); end catch fprintf ('ERROR in legend_10: %s\n', lasterr ()); err_fid = fopen ('legend_10.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_11.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:1; plot (x, x, ';\alpha;', ... x, 2*x, ';\beta=2\alpha;', ... x, 3*x, ';\gamma=3\alpha;'); h = legend (); set (h, 'interpreter', 'tex'); title ('Labels with interpreted Greek text'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_11.png" ... '); tic (); print ('-dpng', 'legend_11.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_11.png" already exists.\n'); end catch fprintf ('ERROR in legend_11: %s\n', lasterr ()); err_fid = fopen ('legend_11.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_12.png', 'file')) rand ('seed', 1); tic (); clf; plot (rand (2)); title ('Labels with TeX interpreter turned off'); h = legend ('Hello_World', 'foo^bar'); set (h, 'interpreter', 'none'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_12.png" ... '); tic (); print ('-dpng', 'legend_12.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_12.png" already exists.\n'); end catch fprintf ('ERROR in legend_12: %s\n', lasterr ()); err_fid = fopen ('legend_12.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_13.png', 'file')) rand ('seed', 1); tic (); clf; plot (1:10, 1:10); title ('a very long label can sometimes cause problems'); legend ('hello very big world', 'location', 'northeastoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_13.png" ... '); tic (); print ('-dpng', 'legend_13.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_13.png" already exists.\n'); end catch fprintf ('ERROR in legend_13: %s\n', lasterr ()); err_fid = fopen ('legend_13.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_14.png', 'file')) rand ('seed', 1); tic (); clf; labels = {}; colororder = get (gca, 'colororder'); for i = 1:5 h = plot (1:100, i + rand (100,1)); hold on; set (h, 'color', colororder(i,:)); labels = {labels{:}, ['Signal ', num2str(i)]}; end hold off; title ({'Signals with random offset and uniform noise'; 'Legend shown below and outside of plot'}); xlabel ('Sample Nr [k]'); ylabel ('Amplitude [V]'); legend (labels, 'location', 'southoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_14.png" ... '); tic (); print ('-dpng', 'legend_14.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_14.png" already exists.\n'); end catch fprintf ('ERROR in legend_14: %s\n', lasterr ()); err_fid = fopen ('legend_14.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_15.png', 'file')) rand ('seed', 1); tic (); clf; x = linspace (0, 10); plot (x, x); hold on; stem (x, x.^2, 'g'); title ('First created object gets first label'); legend ('linear'); hold off; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_15.png" ... '); tic (); print ('-dpng', 'legend_15.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_15.png" already exists.\n'); end catch fprintf ('ERROR in legend_15: %s\n', lasterr ()); err_fid = fopen ('legend_15.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_16.png', 'file')) rand ('seed', 1); tic (); clf; x = linspace (0, 10); plot (x, x, x, x.^2); title ('First created object gets first label'); legend ('linear'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_16.png" ... '); tic (); print ('-dpng', 'legend_16.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_16.png" already exists.\n'); end catch fprintf ('ERROR in legend_16: %s\n', lasterr ()); err_fid = fopen ('legend_16.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_17.png', 'file')) rand ('seed', 1); tic (); clf; x = linspace (0, 10); plot (x, x, x, x.^2); title ('Labels are applied in order of object creation'); legend ('linear', 'quadratic'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_17.png" ... '); tic (); print ('-dpng', 'legend_17.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_17.png" already exists.\n'); end catch fprintf ('ERROR in legend_17: %s\n', lasterr ()); err_fid = fopen ('legend_17.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_18.png', 'file')) rand ('seed', 1); tic (); clf; rand_2x3_data1 = [0.341447, 0.171220, 0.284370; 0.039773, 0.731725, 0.779382]; bar (rand_2x3_data1); ylim ([0 1.0]); title ('legend() works for bar graphs (hggroups)'); legend ({'1st Bar', '2nd Bar', '3rd Bar'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_18.png" ... '); tic (); print ('-dpng', 'legend_18.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_18.png" already exists.\n'); end catch fprintf ('ERROR in legend_18: %s\n', lasterr ()); err_fid = fopen ('legend_18.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_19.png', 'file')) rand ('seed', 1); tic (); clf; rand_2x3_data2 = [0.44804, 0.84368, 0.23012; 0.72311, 0.58335, 0.90531]; bar (rand_2x3_data2); ylim ([0 1.2]); title ('"left" option places text label west of colors'); legend ('1st Bar', '2nd Bar', '3rd Bar'); legend left; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_19.png" ... '); tic (); print ('-dpng', 'legend_19.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_19.png" already exists.\n'); end catch fprintf ('ERROR in legend_19: %s\n', lasterr ()); err_fid = fopen ('legend_19.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_20.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.1:7; h = plot (x,sin(x), x,cos(x), x,sin(x.^2/10), x,cos(x.^2/10)); title ('Only the sin() objects have keylabels'); legend (h([1, 3]), {'sin (x)', 'sin (x^2/10)'}, 'location', 'southwest'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_20.png" ... '); tic (); print ('-dpng', 'legend_20.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_20.png" already exists.\n'); end catch fprintf ('ERROR in legend_20: %s\n', lasterr ()); err_fid = fopen ('legend_20.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_21.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.1:10; plot (x, sin (x), ';sin (x);'); hold all; plot (x, cos (x), ';cos (x);'); hold off; title ('legend constructed from multiple plot calls'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_21.png" ... '); tic (); print ('-dpng', 'legend_21.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_21.png" already exists.\n'); end catch fprintf ('ERROR in legend_21: %s\n', lasterr ()); err_fid = fopen ('legend_21.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_22.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.1:10; plot (x, sin (x), ';sin (x);'); hold all; plot (x, cos (x), ';cos (x);'); hold off; title ('Specified label text overrides previous labels'); legend ({'Sine', 'Cosine'}, 'location', 'northeastoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_22.png" ... '); tic (); print ('-dpng', 'legend_22.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_22.png" already exists.\n'); end catch fprintf ('ERROR in legend_22: %s\n', lasterr ()); err_fid = fopen ('legend_22.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_23.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:10; plot (x, rand (11)); xlabel ('Indices'); ylabel ('Random Values'); title ('Legend ''off'' deletes the legend'); legend (cellstr (num2str ((1:10)')), 'location', 'northeastoutside'); legend off; axis ([0, 10, 0 1]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_23.png" ... '); tic (); print ('-dpng', 'legend_23.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_23.png" already exists.\n'); end catch fprintf ('ERROR in legend_23: %s\n', lasterr ()); err_fid = fopen ('legend_23.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_24.png', 'file')) rand ('seed', 1); tic (); clf; x = (1:5)'; subplot (2,2,1); plot (x, rand (numel (x))); legend (cellstr (num2str (x)), 'location', 'northwestoutside'); subplot (2,2,2); plot (x, rand (numel (x))); legend (cellstr (num2str (x)), 'location', 'northeastoutside'); subplot (2,2,3); plot (x, rand (numel (x))); legend (cellstr (num2str (x)), 'location', 'southwestoutside'); subplot (2,2,4); plot (x, rand (numel (x))); legend (cellstr (num2str (x)), 'location', 'southeastoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_24.png" ... '); tic (); print ('-dpng', 'legend_24.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_24.png" already exists.\n'); end catch fprintf ('ERROR in legend_24: %s\n', lasterr ()); err_fid = fopen ('legend_24.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_25.png', 'file')) rand ('seed', 1); tic (); clf; plot (rand (2)); title ('legend() will warn if extra labels are specified'); legend ('Hello', 'World', 'interpreter', 'foobar'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_25.png" ... '); tic (); print ('-dpng', 'legend_25.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_25.png" already exists.\n'); end catch fprintf ('ERROR in legend_25: %s\n', lasterr ()); err_fid = fopen ('legend_25.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_26.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:10; y1 = rand (size (x)); y2 = rand (size (x)); [ax, h1, h2] = plotyy (x, y1, x, y2); title ('plotyy legend test %1: Blue and Green labels'); legend ([h1, h2], {'Blue', 'Green'}, 'location', 'south'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_26.png" ... '); tic (); print ('-dpng', 'legend_26.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_26.png" already exists.\n'); end catch fprintf ('ERROR in legend_26: %s\n', lasterr ()); err_fid = fopen ('legend_26.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_27.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:10; y1 = rand (size (x)); y2 = rand (size (x)); [ax, h1, h2] = plotyy (x, y1, x, y2); title ('plotyy legend test %2: Blue and Green labels'); legend ({'Blue', 'Green'}, 'location', 'south'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_27.png" ... '); tic (); print ('-dpng', 'legend_27.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_27.png" already exists.\n'); end catch fprintf ('ERROR in legend_27: %s\n', lasterr ()); err_fid = fopen ('legend_27.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_28.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:10; y1 = rand (size (x)); y2 = rand (size (x)); [ax, h1, h2] = plotyy (x, y1, x, y2); title ('plotyy legend test %3: Blue and Green labels'); legend ('Blue', 'Green', 'location', 'south'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_28.png" ... '); tic (); print ('-dpng', 'legend_28.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_28.png" already exists.\n'); end catch fprintf ('ERROR in legend_28: %s\n', lasterr ()); err_fid = fopen ('legend_28.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_29.png', 'file')) rand ('seed', 1); tic (); % bug 36408 clf; option = 'right'; subplot (3,1,1); plot (rand (1,4)); xlabel xlabel; ylabel ylabel; title ('Subplots should adjust to the legend placed outside'); legend ({'1'}, 'location', 'northeastoutside'); legend (option); subplot (3,1,2); plot (rand (1,4)); xlabel xlabel; ylabel ylabel; legend ({'1234567890'}, 'location', 'eastoutside'); legend (option); subplot (3,1,3); plot (rand (1,4)); xlabel xlabel; ylabel ylabel; legend ({'12345678901234567890'}, 'location', 'southeastoutside'); legend (option); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_29.png" ... '); tic (); print ('-dpng', 'legend_29.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_29.png" already exists.\n'); end catch fprintf ('ERROR in legend_29: %s\n', lasterr ()); err_fid = fopen ('legend_29.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_30.png', 'file')) rand ('seed', 1); tic (); % bug 36408 clf; option = 'right'; subplot (3,1,1); plot (rand (1,4)); title ('Subplots should adjust to the legend placed outside'); legend ({'1'}, 'location', 'northwestoutside'); legend (option); subplot (3,1,2); plot (rand (1,4)); legend ({'1234567890'}, 'location', 'westoutside'); legend (option); subplot (3,1,3); plot (rand (1,4)); legend ({'12345678901234567890'}, 'location', 'southwestoutside'); legend (option); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_30.png" ... '); tic (); print ('-dpng', 'legend_30.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_30.png" already exists.\n'); end catch fprintf ('ERROR in legend_30: %s\n', lasterr ()); err_fid = fopen ('legend_30.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_31.png', 'file')) rand ('seed', 1); tic (); % bug 36408 clf; option = 'right'; subplot (3,1,1); plot (rand (1,4)); set (gca (), 'yaxislocation', 'right'); xlabel ('xlabel'); ylabel ('ylabel'); title ('Subplots should adjust to the legend placed outside'); legend ({'1'}, 'location', 'northeastoutside'); legend (option); subplot (3,1,2); plot (rand (1,4)); set (gca (), 'yaxislocation', 'right'); xlabel ('xlabel'); ylabel ('ylabel'); legend ({'1234567890'}, 'location', 'eastoutside'); legend (option); subplot (3,1,3); plot (rand (1,4)); set (gca (), 'yaxislocation', 'right'); xlabel ('xlabel'); ylabel ('ylabel'); legend ({'12345678901234567890'}, 'location', 'southeastoutside'); legend (option); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_31.png" ... '); tic (); print ('-dpng', 'legend_31.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_31.png" already exists.\n'); end catch fprintf ('ERROR in legend_31: %s\n', lasterr ()); err_fid = fopen ('legend_31.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_32.png', 'file')) rand ('seed', 1); tic (); % bug 36408 clf; option = 'right'; subplot (3,1,1); plot (rand (1,4)); set (gca (), 'yaxislocation', 'right'); xlabel ('xlabel'); ylabel ('ylabel'); title ('Subplots should adjust to the legend placed outside'); legend ({'1'}, 'location', 'northwestoutside'); legend (option); subplot (3,1,2); plot (rand (1,4)); set (gca (), 'yaxislocation', 'right'); xlabel ('xlabel'); ylabel ('ylabel'); legend ({'1234567890'}, 'location', 'westoutside'); legend (option); subplot (3,1,3); plot (rand (1,4)); set (gca (), 'yaxislocation', 'right'); xlabel ('xlabel'); ylabel ('ylabel'); legend ({'12345678901234567890'}, 'location', 'southwestoutside'); legend (option); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_32.png" ... '); tic (); print ('-dpng', 'legend_32.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_32.png" already exists.\n'); end catch fprintf ('ERROR in legend_32: %s\n', lasterr ()); err_fid = fopen ('legend_32.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_33.png', 'file')) rand ('seed', 1); tic (); % bug 36408; clf; option = 'right'; subplot (3,1,1); plot (rand (1,4)); set (gca (), 'xaxislocation', 'top'); xlabel ('xlabel'); ylabel ('ylabel'); title ('Subplots should adjust to the legend placed outside'); legend ({'1'}, 'location', 'northwestoutside'); legend (option); subplot (3,1,2); plot (rand (1,4)); set (gca (), 'xaxislocation', 'top'); xlabel ('xlabel'); ylabel ('ylabel'); legend ({'1234567890'}, 'location', 'westoutside'); legend (option); subplot (3,1,3); plot (rand (1,4)); set (gca (), 'xaxislocation', 'top'); xlabel ('xlabel'); ylabel ('ylabel'); legend ({'12345678901234567890'}, 'location', 'southwestoutside'); legend (option); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_33.png" ... '); tic (); print ('-dpng', 'legend_33.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_33.png" already exists.\n'); end catch fprintf ('ERROR in legend_33: %s\n', lasterr ()); err_fid = fopen ('legend_33.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_34.png', 'file')) rand ('seed', 1); tic (); % bug 39697 clf; plot (1:10); legend ('Legend Text'); title ({'Multi-line', 'titles', 'are a', 'problem'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_34.png" ... '); tic (); print ('-dpng', 'legend_34.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_34.png" already exists.\n'); end catch fprintf ('ERROR in legend_34: %s\n', lasterr ()); err_fid = fopen ('legend_34.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('legend_35.png', 'file')) rand ('seed', 1); tic (); clf; colormap (cool (64)); surf (peaks ()); legend ('peaks()') title ('legend() works for surface objects too'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "legend_35.png" ... '); tic (); print ('-dpng', 'legend_35.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "legend_35.png" already exists.\n'); end catch fprintf ('ERROR in legend_35: %s\n', lasterr ()); err_fid = fopen ('legend_35.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('pbaspect_01.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.01:4; plot (x,cos(x), x,sin(x)); pbaspect ([1 1 1]); title ('plot box is square'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "pbaspect_01.png" ... '); tic (); print ('-dpng', 'pbaspect_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "pbaspect_01.png" already exists.\n'); end catch fprintf ('ERROR in pbaspect_01: %s\n', lasterr ()); err_fid = fopen ('pbaspect_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('pbaspect_02.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.01:4;; plot (x,cos(x), x,sin(x)); pbaspect ([2 1 1]); title ('plot box aspect ratio is 2x1'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "pbaspect_02.png" ... '); tic (); print ('-dpng', 'pbaspect_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "pbaspect_02.png" already exists.\n'); end catch fprintf ('ERROR in pbaspect_02: %s\n', lasterr ()); err_fid = fopen ('pbaspect_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('pbaspect_03.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.01:4; plot (x,cos(x), x,sin(x)); daspect ([1 1 1]); pbaspect ([2 1 1]); title ('plot box is 2x1, and axes [0 4 -1 1]'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "pbaspect_03.png" ... '); tic (); print ('-dpng', 'pbaspect_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "pbaspect_03.png" already exists.\n'); end catch fprintf ('ERROR in pbaspect_03: %s\n', lasterr ()); err_fid = fopen ('pbaspect_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('shading_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); sombrero (41); shading faceted; title ('shading ''faceted'''); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "shading_01.png" ... '); tic (); print ('-dpng', 'shading_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "shading_01.png" already exists.\n'); end catch fprintf ('ERROR in shading_01: %s\n', lasterr ()); err_fid = fopen ('shading_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('shading_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); sombrero (41); shading flat; title ('shading ''flat'''); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "shading_02.png" ... '); tic (); print ('-dpng', 'shading_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "shading_02.png" already exists.\n'); end catch fprintf ('ERROR in shading_02: %s\n', lasterr ()); err_fid = fopen ('shading_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('shading_03.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); sombrero (41); shading interp; title ('shading ''interp'''); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "shading_03.png" ... '); tic (); print ('-dpng', 'shading_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "shading_03.png" already exists.\n'); end catch fprintf ('ERROR in shading_03: %s\n', lasterr ()); err_fid = fopen ('shading_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('shading_04.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); pcolor (peaks ()); shading faceted; title ('shading ''faceted'''); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "shading_04.png" ... '); tic (); print ('-dpng', 'shading_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "shading_04.png" already exists.\n'); end catch fprintf ('ERROR in shading_04: %s\n', lasterr ()); err_fid = fopen ('shading_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('shading_05.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); pcolor (peaks ()); shading flat; title ('shading ''flat'''); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "shading_05.png" ... '); tic (); print ('-dpng', 'shading_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "shading_05.png" already exists.\n'); end catch fprintf ('ERROR in shading_05: %s\n', lasterr ()); err_fid = fopen ('shading_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('shading_06.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); pcolor (peaks ()); shading interp; title ('shading ''interp'''); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "shading_06.png" ... '); tic (); print ('-dpng', 'shading_06.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "shading_06.png" already exists.\n'); end catch fprintf ('ERROR in shading_06: %s\n', lasterr ()); err_fid = fopen ('shading_06.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('text_01.png', 'file')) rand ('seed', 1); tic (); clf; ha = {'left', 'center', 'right'}; va = {'bottom', 'middle', 'top'}; x = [0.25 0.5 0.75]; y = x; for t = 0:30:359; for nh = 1:numel (ha) for nv = 1:numel (va) text (x(nh), y(nv), 'Hello World', ... 'rotation', t, ... 'horizontalalignment', ha{nh}, ... 'verticalalignment', va{nv}); end end end set (gca, 'xtick', [0.25, 0.5, 0.75], ... 'xticklabel', ha, ... 'ytick', [0.25, 0.5, 0.75], ... 'yticklabel', va); axis ([0 1 0 1]); xlabel ('horizontal alignment'); ylabel ('vertical alignment'); title ('text alignment and rotation (0:30:360 degrees)'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "text_01.png" ... '); tic (); print ('-dpng', 'text_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "text_01.png" already exists.\n'); end catch fprintf ('ERROR in text_01: %s\n', lasterr ()); err_fid = fopen ('text_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('text_02.png', 'file')) rand ('seed', 1); tic (); clf; h = mesh (peaks, 'edgecolor', 0.7 * [1 1 1], ... 'facecolor', 'none', ... 'facealpha', 0); for t = 0:45:359; text (25, 25, 0, 'Vertical Alignment = Bottom', ... 'rotation', t, ... 'horizontalalignment', 'left', ... 'verticalalignment', 'bottom'); end caxis ([-100 100]); title ('Vertically Aligned at Bottom'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "text_02.png" ... '); tic (); print ('-dpng', 'text_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "text_02.png" already exists.\n'); end catch fprintf ('ERROR in text_02: %s\n', lasterr ()); err_fid = fopen ('text_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('text_03.png', 'file')) rand ('seed', 1); tic (); clf; axis ([0 8 0 8]); title (['1st title';'2nd title']); xlabel (['1st xlabel';'2nd xlabel']); ylabel (['1st ylabel';'2nd ylabel']); text (4, 4, {'Hello', 'World'}, ... 'horizontalalignment', 'center', ... 'verticalalignment', 'middle'); grid on; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "text_03.png" ... '); tic (); print ('-dpng', 'text_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "text_03.png" already exists.\n'); end catch fprintf ('ERROR in text_03: %s\n', lasterr ()); err_fid = fopen ('text_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('text_04.png', 'file')) rand ('seed', 1); tic (); clf; h = mesh (peaks (), 'edgecolor', 0.7 * [1 1 1], ... 'facecolor', 'none', ... 'facealpha', 0); title (['1st title';'2nd title']); xlabel (['1st xlabel';'2nd xlabel']); ylabel (['1st ylabel';'2nd ylabel']); zlabel (['1st zlabel';'2nd zlabel']); text (0, 0, 5, {'Hello', 'World'}, ... 'horizontalalignment', 'center', ... 'verticalalignment', 'middle'); hold on; plot3 (0, 0, 5, '+k'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "text_04.png" ... '); tic (); print ('-dpng', 'text_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "text_04.png" already exists.\n'); end catch fprintf ('ERROR in text_04: %s\n', lasterr ()); err_fid = fopen ('text_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('text_05.png', 'file')) rand ('seed', 1); tic (); clf; h = text (0.5, 0.3, 'char'); assert ('char', class (get (h, 'string'))); h = text (0.5, 0.4, ['char row 1'; 'char row 2']); assert ('char', class (get (h, 'string'))); h = text (0.5, 0.6, {'cell2str (1,1)', 'cell2str (1,2)'; 'cell2str (2,1)', 'cell2str (2,2)'}); assert ('cell', class (get (h, 'string'))); h = text (0.5, 0.8, 'foobar'); set (h, 'string', 1:3); h = text ([0.1, 0.1], [0.3, 0.4], 'one string & two objects'); assert ('char', class (get (h(1), 'string'))); assert ('char', class (get (h(2), 'string'))); h = text ([0.1, 0.1], [0.5, 0.6], {'one cellstr & two objects'}); assert ('cell', class (get (h(1), 'string'))); assert ('cell', class (get (h(2), 'string'))); h = text ([0.1, 0.1], [0.7, 0.8], {'cellstr 1 object 1', 'cellstr 2 object 2'}); assert ('char', class (get (h(1), 'string'))); assert ('char', class (get (h(2), 'string'))); h = text ([0.1, 0.1], [0.1, 0.2], ['1st string & 1st object'; '2nd string & 2nd object']); assert ('char', class (get (h(1), 'string'))); assert ('char', class (get (h(2), 'string'))); h = text (0.7, 0.6, 'single string'); assert ('char', class (get (h, 'string'))); h = text (0.7, 0.5, {'single cell-string'}); assert ('cell', class (get (h, 'string'))); xlabel (1:2); ylabel (1:2); title (1:2); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "text_05.png" ... '); tic (); print ('-dpng', 'text_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "text_05.png" already exists.\n'); end catch fprintf ('ERROR in text_05: %s\n', lasterr ()); err_fid = fopen ('text_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('title_01.png', 'file')) rand ('seed', 1); tic (); clf; ax = axes (); h = get (ax, 'title'); title ('Test Title Text'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "title_01.png" ... '); tic (); print ('-dpng', 'title_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "title_01.png" already exists.\n'); end catch fprintf ('ERROR in title_01: %s\n', lasterr ()); err_fid = fopen ('title_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('title_02.png', 'file')) rand ('seed', 1); tic (); clf; ax = axes (); h = get (ax, 'title'); title ({'Multi-line'; 'Title'; 'Text'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "title_02.png" ... '); tic (); print ('-dpng', 'title_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "title_02.png" already exists.\n'); end catch fprintf ('ERROR in title_02: %s\n', lasterr ()); err_fid = fopen ('title_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('title_03.png', 'file')) rand ('seed', 1); tic (); clf; plot3 ([0,1], [0,1], [0,1]); h = get (gca, 'title'); title ('Test FontSize Property', 'fontsize', 16); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "title_03.png" ... '); tic (); print ('-dpng', 'title_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "title_03.png" already exists.\n'); end catch fprintf ('ERROR in title_03: %s\n', lasterr ()); err_fid = fopen ('title_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('xlim_01.png', 'file')) rand ('seed', 1); tic (); clf; line (); xlim ([0.2, 0.8]); title ('xlim is [0.2, 0.8]'); assert (xlim (), [0.2, 0.8]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "xlim_01.png" ... '); tic (); print ('-dpng', 'xlim_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "xlim_01.png" already exists.\n'); end catch fprintf ('ERROR in xlim_01: %s\n', lasterr ()); err_fid = fopen ('xlim_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('xlim_02.png', 'file')) rand ('seed', 1); tic (); clf; line (); xlim ('auto'); title ('xlim is auto'); assert (xlim ('mode'), 'auto'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "xlim_02.png" ... '); tic (); print ('-dpng', 'xlim_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "xlim_02.png" already exists.\n'); end catch fprintf ('ERROR in xlim_02: %s\n', lasterr ()); err_fid = fopen ('xlim_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('xlim_03.png', 'file')) rand ('seed', 1); tic (); clf; plot3 ([0,1], [0,1], [0,1]); xlim ([0.2, 0.8]); title ('xlim is [0.2, 0.8]'); assert (xlim (), [0.2, 0.8]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "xlim_03.png" ... '); tic (); print ('-dpng', 'xlim_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "xlim_03.png" already exists.\n'); end catch fprintf ('ERROR in xlim_03: %s\n', lasterr ()); err_fid = fopen ('xlim_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('xlim_04.png', 'file')) rand ('seed', 1); tic (); clf; plot3 ([0,1], [0,1], [0,1]); xlim ('auto'); title ('xlim is auto'); assert (xlim ('mode'), 'auto'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "xlim_04.png" ... '); tic (); print ('-dpng', 'xlim_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "xlim_04.png" already exists.\n'); end catch fprintf ('ERROR in xlim_04: %s\n', lasterr ()); err_fid = fopen ('xlim_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ylim_01.png', 'file')) rand ('seed', 1); tic (); clf; line (); ylim ([0.2, 0.8]); title ('ylim is [0.2, 0.8]'); assert (ylim (), [0.2, 0.8]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ylim_01.png" ... '); tic (); print ('-dpng', 'ylim_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ylim_01.png" already exists.\n'); end catch fprintf ('ERROR in ylim_01: %s\n', lasterr ()); err_fid = fopen ('ylim_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ylim_02.png', 'file')) rand ('seed', 1); tic (); clf; line (); ylim ('auto'); title ('ylim is auto'); assert (ylim ('mode'), 'auto'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ylim_02.png" ... '); tic (); print ('-dpng', 'ylim_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ylim_02.png" already exists.\n'); end catch fprintf ('ERROR in ylim_02: %s\n', lasterr ()); err_fid = fopen ('ylim_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ylim_03.png', 'file')) rand ('seed', 1); tic (); clf; plot3 ([0,1], [0,1], [0,1]); ylim ([0.2, 0.8]); title ('ylim is [0.2, 0.8]'); assert (ylim (), [0.2, 0.8]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ylim_03.png" ... '); tic (); print ('-dpng', 'ylim_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ylim_03.png" already exists.\n'); end catch fprintf ('ERROR in ylim_03: %s\n', lasterr ()); err_fid = fopen ('ylim_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ylim_04.png', 'file')) rand ('seed', 1); tic (); clf; plot3 ([0,1], [0,1], [0,1]); ylim ('auto'); title ('ylim is auto'); assert (ylim ('mode'), 'auto'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ylim_04.png" ... '); tic (); print ('-dpng', 'ylim_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ylim_04.png" already exists.\n'); end catch fprintf ('ERROR in ylim_04: %s\n', lasterr ()); err_fid = fopen ('ylim_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('zlim_01.png', 'file')) rand ('seed', 1); tic (); clf; line (); zlim ([0.2, 0.8]); title ('zlim is [0.2, 0.8]'); assert (zlim (), [0.2, 0.8]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "zlim_01.png" ... '); tic (); print ('-dpng', 'zlim_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "zlim_01.png" already exists.\n'); end catch fprintf ('ERROR in zlim_01: %s\n', lasterr ()); err_fid = fopen ('zlim_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('zlim_02.png', 'file')) rand ('seed', 1); tic (); clf; line (); zlim ('auto'); title ('zlim is auto'); assert (zlim ('mode'), 'auto'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "zlim_02.png" ... '); tic (); print ('-dpng', 'zlim_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "zlim_02.png" already exists.\n'); end catch fprintf ('ERROR in zlim_02: %s\n', lasterr ()); err_fid = fopen ('zlim_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('zlim_03.png', 'file')) rand ('seed', 1); tic (); clf; plot3 ([0,1], [0,1], [0,1]); zlim ([0.2, 0.8]); title ('zlim is [0.2, 0.8]'); assert (zlim (), [0.2, 0.8]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "zlim_03.png" ... '); tic (); print ('-dpng', 'zlim_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "zlim_03.png" already exists.\n'); end catch fprintf ('ERROR in zlim_03: %s\n', lasterr ()); err_fid = fopen ('zlim_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('zlim_04.png', 'file')) rand ('seed', 1); tic (); clf; plot3 ([0,1], [0,1], [0,1]); zlim ('auto'); title ('zlim is auto'); assert (zlim ('mode'), 'auto'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "zlim_04.png" ... '); tic (); print ('-dpng', 'zlim_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "zlim_04.png" already exists.\n'); end catch fprintf ('ERROR in zlim_04: %s\n', lasterr ()); err_fid = fopen ('zlim_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end close all try if (! exist ('area_01.png', 'file')) rand ('seed', 1); tic (); %% Verify identity sin^2 + cos^2 = 1 clf; t = linspace (0, 2*pi, 100)'; y = [sin(t).^2, cos(t).^2]; area (t, y); axis tight legend ('sin^2', 'cos^2', 'location', 'NorthEastOutside'); title ('area() plot'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "area_01.png" ... '); tic (); print ('-dpng', 'area_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "area_01.png" already exists.\n'); end catch fprintf ('ERROR in area_01: %s\n', lasterr ()); err_fid = fopen ('area_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('area_02.png', 'file')) rand ('seed', 1); tic (); %% Show effects of setting BaseValue clf; x = [-2:0.1:2]'; y = x.^2 - 1; subplot (1, 2, 1) area (x, y); title ({'Parabola y = x^2 -1';'BaseValue = 0'}); subplot (1, 2, 2) h = area (x, y); set (h, 'basevalue', -1); title ({'Parabola y = x^2 -1';'BaseValue = -1'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "area_02.png" ... '); tic (); print ('-dpng', 'area_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "area_02.png" already exists.\n'); end catch fprintf ('ERROR in area_02: %s\n', lasterr ()); err_fid = fopen ('area_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('area_03.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:10; y = rand (size (x)); h = area (x, y); set (h, 'ydata', sort (get (h, 'ydata'))) title ('area() plot of sorted data'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "area_03.png" ... '); tic (); print ('-dpng', 'area_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "area_03.png" already exists.\n'); end catch fprintf ('ERROR in area_03: %s\n', lasterr ()); err_fid = fopen ('area_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('bar_01.png', 'file')) rand ('seed', 1); tic (); clf; y = rand (11, 1); h = bar (y); set (h, 'ydata', sort (rand (11, 1))); title ('bar() graph'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "bar_01.png" ... '); tic (); print ('-dpng', 'bar_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "bar_01.png" already exists.\n'); end catch fprintf ('ERROR in bar_01: %s\n', lasterr ()); err_fid = fopen ('bar_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('bar_02.png', 'file')) rand ('seed', 1); tic (); clf; h = bar (rand (5, 3)); set (h(1), 'facecolor', 'r'); set (h(2), 'facecolor', 'g'); set (h(3), 'facecolor', 'b'); title ('bar() graph w/multiple bars'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "bar_02.png" ... '); tic (); print ('-dpng', 'bar_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "bar_02.png" already exists.\n'); end catch fprintf ('ERROR in bar_02: %s\n', lasterr ()); err_fid = fopen ('bar_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('bar_03.png', 'file')) rand ('seed', 1); tic (); clf; h = bar (rand (5, 3), 'stacked'); title ('bar() graph with stacked style'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "bar_03.png" ... '); tic (); print ('-dpng', 'bar_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "bar_03.png" already exists.\n'); end catch fprintf ('ERROR in bar_03: %s\n', lasterr ()); err_fid = fopen ('bar_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('barh_01.png', 'file')) rand ('seed', 1); tic (); clf; x = rand (10, 1); barh (x); title ('barh() graph') t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "barh_01.png" ... '); tic (); print ('-dpng', 'barh_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "barh_01.png" already exists.\n'); end catch fprintf ('ERROR in barh_01: %s\n', lasterr ()); err_fid = fopen ('barh_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('barh_02.png', 'file')) rand ('seed', 1); tic (); clf; h = barh (rand (5, 3)); set (h(1), 'facecolor', 'r') set (h(2), 'facecolor', 'g') set (h(3), 'facecolor', 'b') title ('barh() graph w/multiple bars') t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "barh_02.png" ... '); tic (); print ('-dpng', 'barh_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "barh_02.png" already exists.\n'); end catch fprintf ('ERROR in barh_02: %s\n', lasterr ()); err_fid = fopen ('barh_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); imagesc (x); colorbar (); title ('colorbar() example'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_01.png" ... '); tic (); print ('-dpng', 'colorbar_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_01.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_01: %s\n', lasterr ()); err_fid = fopen ('colorbar_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); imagesc (x); colorbar ('westoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_02.png" ... '); tic (); print ('-dpng', 'colorbar_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_02.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_02: %s\n', lasterr ()); err_fid = fopen ('colorbar_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_03.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); imagesc (x); colorbar ('peer', gca, 'northoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_03.png" ... '); tic (); print ('-dpng', 'colorbar_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_03.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_03: %s\n', lasterr ()); err_fid = fopen ('colorbar_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_04.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); imagesc (x); colorbar ('southoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_04.png" ... '); tic (); print ('-dpng', 'colorbar_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_04.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_04: %s\n', lasterr ()); err_fid = fopen ('colorbar_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_05.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); contour (peaks ()); colorbar ('west'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_05.png" ... '); tic (); print ('-dpng', 'colorbar_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_05.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_05: %s\n', lasterr ()); err_fid = fopen ('colorbar_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_06.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); subplot (2,2,1); contour (peaks ()); colorbar ('east'); subplot (2,2,2); contour (peaks ()); colorbar ('west'); subplot (2,2,3); contour (peaks ()); colorbar ('north'); subplot (2,2,4); contour (peaks ()); colorbar ('south'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_06.png" ... '); tic (); print ('-dpng', 'colorbar_06.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_06.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_06: %s\n', lasterr ()); err_fid = fopen ('colorbar_06.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_07.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); subplot (2,2,1); imagesc (x); colorbar (); subplot (2,2,2); imagesc (x); colorbar ('westoutside'); subplot (2,2,3); imagesc (x); colorbar ('northoutside'); subplot (2,2,4); imagesc (x); colorbar ('southoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_07.png" ... '); tic (); print ('-dpng', 'colorbar_07.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_07.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_07: %s\n', lasterr ()); err_fid = fopen ('colorbar_07.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_08.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); subplot (1,2,1); imagesc (x); axis square; colorbar (); subplot (1,2,2); imagesc (x); axis square; colorbar ('westoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_08.png" ... '); tic (); print ('-dpng', 'colorbar_08.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_08.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_08: %s\n', lasterr ()); err_fid = fopen ('colorbar_08.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_09.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); subplot (1,2,1); imagesc (x); axis square; colorbar ('northoutside'); subplot (1,2,2); imagesc (x); axis square; colorbar ('southoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_09.png" ... '); tic (); print ('-dpng', 'colorbar_09.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_09.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_09: %s\n', lasterr ()); err_fid = fopen ('colorbar_09.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_10.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); subplot (2,1,1); imagesc (x); axis square; colorbar (); subplot (2,1,2); imagesc (x); axis square; colorbar ('westoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_10.png" ... '); tic (); print ('-dpng', 'colorbar_10.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_10.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_10: %s\n', lasterr ()); err_fid = fopen ('colorbar_10.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_11.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); subplot (2,1,1); imagesc (x); axis square; colorbar ('northoutside'); subplot (2,1,2); imagesc (x); axis square; colorbar ('southoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_11.png" ... '); tic (); print ('-dpng', 'colorbar_11.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_11.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_11: %s\n', lasterr ()); err_fid = fopen ('colorbar_11.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_12.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); subplot (1,2,1); imagesc (x); colorbar (); subplot (1,2,2); imagesc (x); colorbar ('westoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_12.png" ... '); tic (); print ('-dpng', 'colorbar_12.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_12.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_12: %s\n', lasterr ()); err_fid = fopen ('colorbar_12.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_13.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); subplot (1,2,1); imagesc (x); colorbar ('northoutside'); subplot (1,2,2); imagesc (x); colorbar ('southoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_13.png" ... '); tic (); print ('-dpng', 'colorbar_13.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_13.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_13: %s\n', lasterr ()); err_fid = fopen ('colorbar_13.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_14.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); subplot (2,1,1); imagesc (x); colorbar (); subplot (2,1,2); imagesc (x); colorbar ('westoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_14.png" ... '); tic (); print ('-dpng', 'colorbar_14.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_14.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_14: %s\n', lasterr ()); err_fid = fopen ('colorbar_14.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_15.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); subplot (2,1,1); imagesc (x); colorbar ('northoutside'); subplot (2,1,2); imagesc (x); colorbar ('southoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_15.png" ... '); tic (); print ('-dpng', 'colorbar_15.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_15.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_15: %s\n', lasterr ()); err_fid = fopen ('colorbar_15.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_16.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); subplot (1,2,1); contour (x); axis square; colorbar ('east'); xlim ([1, 64]); ylim ([1, 64]); subplot (1,2,2); contour (x); colorbar ('west'); xlim ([1, 64]); ylim ([1, 64]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_16.png" ... '); tic (); print ('-dpng', 'colorbar_16.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_16.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_16: %s\n', lasterr ()); err_fid = fopen ('colorbar_16.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_17.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); contour (x); xlim ([1, 64]); ylim ([1, 64]); colorbar (); colorbar off; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_17.png" ... '); tic (); print ('-dpng', 'colorbar_17.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_17.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_17: %s\n', lasterr ()); err_fid = fopen ('colorbar_17.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_18.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 64; x = kron (1:n, ones (n,1)); x = abs (x - x.'); contour (x); xlim ([1, 64]); ylim ([1, 64]); colorbar (); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_18.png" ... '); tic (); print ('-dpng', 'colorbar_18.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_18.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_18: %s\n', lasterr ()); err_fid = fopen ('colorbar_18.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_19.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); imagesc (1 ./ hilb (99)); h = colorbar (); set (h, 'yscale', 'log'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_19.png" ... '); tic (); print ('-dpng', 'colorbar_19.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_19.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_19: %s\n', lasterr ()); err_fid = fopen ('colorbar_19.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_20.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); imagesc (log10 (1 ./ hilb (99))); h = colorbar (); ytick = get (h, 'ytick'); set (h, 'yticklabel', sprintf ('10^{%g}|', ytick)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_20.png" ... '); tic (); print ('-dpng', 'colorbar_20.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_20.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_20: %s\n', lasterr ()); err_fid = fopen ('colorbar_20.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_21.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 5; x = linspace (0,5,n); y = linspace (0,1,n); imagesc (1 ./ hilb (n)); axis equal; colorbar (); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_21.png" ... '); tic (); print ('-dpng', 'colorbar_21.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_21.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_21: %s\n', lasterr ()); err_fid = fopen ('colorbar_21.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_22.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 5; x = linspace (0,5,n); y = linspace (0,1,n); imagesc (x, y, 1 ./ hilb (n)); axis equal; colorbar (); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_22.png" ... '); tic (); print ('-dpng', 'colorbar_22.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_22.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_22: %s\n', lasterr ()); err_fid = fopen ('colorbar_22.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_23.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); n = 5; x = linspace (0,5,n); y = linspace (0,1,n); imagesc (y, x, 1 ./ hilb (n)); axis equal; colorbar (); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_23.png" ... '); tic (); print ('-dpng', 'colorbar_23.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_23.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_23: %s\n', lasterr ()); err_fid = fopen ('colorbar_23.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_24.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); axes; colorbar (); hold on; contour (peaks ()); hold off; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_24.png" ... '); tic (); print ('-dpng', 'colorbar_24.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_24.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_24: %s\n', lasterr ()); err_fid = fopen ('colorbar_24.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_25.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); plot ([0, 2]); colorbar ('east'); axis square; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_25.png" ... '); tic (); print ('-dpng', 'colorbar_25.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_25.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_25: %s\n', lasterr ()); err_fid = fopen ('colorbar_25.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_26.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); plot ([0, 2]); colorbar ('eastoutside'); axis square; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_26.png" ... '); tic (); print ('-dpng', 'colorbar_26.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_26.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_26: %s\n', lasterr ()); err_fid = fopen ('colorbar_26.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_27.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); pcolor (peaks (20)); shading interp; axis ('tight', 'square'); colorbar (); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_27.png" ... '); tic (); print ('-dpng', 'colorbar_27.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_27.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_27: %s\n', lasterr ()); err_fid = fopen ('colorbar_27.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_28.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); plot ([0, 2]); colorbar ('east'); axis equal; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_28.png" ... '); tic (); print ('-dpng', 'colorbar_28.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_28.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_28: %s\n', lasterr ()); err_fid = fopen ('colorbar_28.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorbar_29.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); plot ([0, 2]); colorbar ('eastoutside'); axis equal; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorbar_29.png" ... '); tic (); print ('-dpng', 'colorbar_29.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorbar_29.png" already exists.\n'); end catch fprintf ('ERROR in colorbar_29: %s\n', lasterr ()); err_fid = fopen ('colorbar_29.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('comet_01.png', 'file')) rand ('seed', 1); tic (); clf; title ('comet() animation'); hold on; t = 0:.1:2*pi; x = cos (2*t) .* (cos (t).^2); y = sin (2*t) .* (sin (t).^2); comet (x, y, 0.05); hold off; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "comet_01.png" ... '); tic (); print ('-dpng', 'comet_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "comet_01.png" already exists.\n'); end catch fprintf ('ERROR in comet_01: %s\n', lasterr ()); err_fid = fopen ('comet_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('comet3_01.png', 'file')) rand ('seed', 1); tic (); clf; title ('comet3() animation'); view (3); hold on; t = 0:pi/20:5*pi; comet3 (cos (t), sin (t), t, 0.05); hold off; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "comet3_01.png" ... '); tic (); print ('-dpng', 'comet3_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "comet3_01.png" already exists.\n'); end catch fprintf ('ERROR in comet3_01: %s\n', lasterr ()); err_fid = fopen ('comet3_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('compass_01.png', 'file')) rand ('seed', 1); tic (); clf; randn_9x1_data = [-2.555884; 0.394974; -0.191871; -1.147024; 1.355425; -0.437335; -0.014370; -0.941312; 1.240300]; randn_1x9_data = [1.42934, -1.10821, -1.70404, 0.63357, -0.68337, -1.19771, -0.96502, -1.12810, 0.22457]; a = toeplitz ([1;randn_9x1_data], [1,randn_1x9_data]); compass (eig (a)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "compass_01.png" ... '); tic (); print ('-dpng', 'compass_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "compass_01.png" already exists.\n'); end catch fprintf ('ERROR in compass_01: %s\n', lasterr ()); err_fid = fopen ('compass_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('contour_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [x, y, z] = peaks (); contour (x, y, z); title ({'contour() plot (isolines of constant Z)'; 'Z = peaks()'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "contour_01.png" ... '); tic (); print ('-dpng', 'contour_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "contour_01.png" already exists.\n'); end catch fprintf ('ERROR in contour_01: %s\n', lasterr ()); err_fid = fopen ('contour_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('contour_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [theta, r] = meshgrid (linspace (0,2*pi,64), linspace (0,1,64)); [X, Y] = pol2cart (theta, r); Z = sin (2*theta) .* (1-r); contour (X, Y, abs (Z), 10); title ({'contour() plot'; 'polar fcn: Z = sin (2*theta) * (1-r)'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "contour_02.png" ... '); tic (); print ('-dpng', 'contour_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "contour_02.png" already exists.\n'); end catch fprintf ('ERROR in contour_02: %s\n', lasterr ()); err_fid = fopen ('contour_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('contour_03.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); z = peaks (); contour (z, [0 0]); title ({'contour() plot with single isoline at Z == 0'; 'Z = peaks()'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "contour_03.png" ... '); tic (); print ('-dpng', 'contour_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "contour_03.png" already exists.\n'); end catch fprintf ('ERROR in contour_03: %s\n', lasterr ()); err_fid = fopen ('contour_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('contour3_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap (cool (64)); surf (peaks (19), 'facecolor', 'none', 'edgecolor', [0.85 0.85 0.85]); hold on; contour3 (peaks (19)); hold off; axis tight; zlim auto; view (315, 17); title ({'contour3 of peaks() function', 'gray surf() shows peaks function'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "contour3_01.png" ... '); tic (); print ('-dpng', 'contour3_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "contour3_01.png" already exists.\n'); end catch fprintf ('ERROR in contour3_01: %s\n', lasterr ()); err_fid = fopen ('contour3_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('contourf_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [x, y, z] = peaks (50); contourf (x, y, z, -7:9); title ({'contourf() plot (filled contour lines)'; 'Z = peaks()'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "contourf_01.png" ... '); tic (); print ('-dpng', 'contourf_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "contourf_01.png" already exists.\n'); end catch fprintf ('ERROR in contourf_01: %s\n', lasterr ()); err_fid = fopen ('contourf_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('contourf_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [theta, r] = meshgrid (linspace (0,2*pi,64), linspace (0,1,64)); [X, Y] = pol2cart (theta, r); Z = sin (2*theta) .* (1-r); contourf (X, Y, abs (Z), 10); title ({'contourf() plot'; 'polar fcn: Z = sin (2*theta) * (1-r)'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "contourf_02.png" ... '); tic (); print ('-dpng', 'contourf_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "contourf_02.png" already exists.\n'); end catch fprintf ('ERROR in contourf_02: %s\n', lasterr ()); err_fid = fopen ('contourf_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('contourf_03.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); x = linspace (-2, 2); [x, y] = meshgrid (x); z = sqrt (x.^2 + y.^2) ./ (x.^2 + y.^2 + 1); contourf (x, y, z, [0.4, 0.4]); title ('Hole should be filled with the background color'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "contourf_03.png" ... '); tic (); print ('-dpng', 'contourf_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "contourf_03.png" already exists.\n'); end catch fprintf ('ERROR in contourf_03: %s\n', lasterr ()); err_fid = fopen ('contourf_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('cylinder_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [x, y, z] = cylinder (10:-1:0, 50); surf (x, y, z); title ('cylinder() with linearly shrinking radius produces a cone'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "cylinder_01.png" ... '); tic (); print ('-dpng', 'cylinder_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "cylinder_01.png" already exists.\n'); end catch fprintf ('ERROR in cylinder_01: %s\n', lasterr ()); err_fid = fopen ('cylinder_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ellipsoid_01.png', 'file')) rand ('seed', 1); tic (); clf; ellipsoid (0, 0, 1, 2, 3, 4, 20); title ('ellipsoid()'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ellipsoid_01.png" ... '); tic (); print ('-dpng', 'ellipsoid_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ellipsoid_01.png" already exists.\n'); end catch fprintf ('ERROR in ellipsoid_01: %s\n', lasterr ()); err_fid = fopen ('ellipsoid_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('errorbar_01.png', 'file')) rand ('seed', 1); tic (); clf; rand_1x11_data1 = [0.82712, 0.50325, 0.35613, 0.77089, 0.20474, 0.69160, 0.30858, 0.88225, 0.35187, 0.14168, 0.54270]; rand_1x11_data2 = [0.506375, 0.330106, 0.017982, 0.859270, 0.140641, 0.327839, 0.275886, 0.162453, 0.807592, 0.318509, 0.921112]; errorbar (0:10, rand_1x11_data1, 0.25*rand_1x11_data2); title ('errorbar() with Y errorbars'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "errorbar_01.png" ... '); tic (); print ('-dpng', 'errorbar_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "errorbar_01.png" already exists.\n'); end catch fprintf ('ERROR in errorbar_01: %s\n', lasterr ()); err_fid = fopen ('errorbar_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('errorbar_02.png', 'file')) rand ('seed', 1); tic (); clf; rand_1x11_data3 = [0.423650, 0.142331, 0.213195, 0.129301, 0.975891, 0.012872, 0.635327, 0.338829, 0.764997, 0.401798, 0.551850]; rand_1x11_data4 = [0.682566, 0.456342, 0.132390, 0.341292, 0.108633, 0.601553, 0.040455, 0.146665, 0.309187, 0.586291, 0.540149]; errorbar (0:10, rand_1x11_data3, rand_1x11_data4, '>'); title ('errorbar() with X errorbars'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "errorbar_02.png" ... '); tic (); print ('-dpng', 'errorbar_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "errorbar_02.png" already exists.\n'); end catch fprintf ('ERROR in errorbar_02: %s\n', lasterr ()); err_fid = fopen ('errorbar_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('errorbar_03.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.5:2*pi; err = x/30; y1 = sin (x); y2 = cos (x); errorbar (x, y1, err, '~', x, y2, err, '>'); legend ('Y errbar', 'X errbar'); title ('errorbar() with 2 datasets'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "errorbar_03.png" ... '); tic (); print ('-dpng', 'errorbar_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "errorbar_03.png" already exists.\n'); end catch fprintf ('ERROR in errorbar_03: %s\n', lasterr ()); err_fid = fopen ('errorbar_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('errorbar_04.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.5:2*pi; err = x/30; y1 = sin (x); y2 = cos (x); errorbar (x, y1, err, err, '#r', x, y2, err, err, '#~'); legend ('X errbox', 'Y errbox'); title ('errorbar() with error boxes'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "errorbar_04.png" ... '); tic (); print ('-dpng', 'errorbar_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "errorbar_04.png" already exists.\n'); end catch fprintf ('ERROR in errorbar_04: %s\n', lasterr ()); err_fid = fopen ('errorbar_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('errorbar_05.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.5:2*pi; err = x/30; y1 = sin (x); y2 = cos (x); errorbar (x, y1, err, err, err, err, '~>', ... x, y2, err, err, err, err, '#~>-*'); legend ('X-Y errbars', 'X-Y errboxes'); title ('errorbar() with X-Y errorbars and error boxes'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "errorbar_05.png" ... '); tic (); print ('-dpng', 'errorbar_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "errorbar_05.png" already exists.\n'); end catch fprintf ('ERROR in errorbar_05: %s\n', lasterr ()); err_fid = fopen ('errorbar_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezcontour_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); f = @(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2); ezcontour (f, [-3, 3]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezcontour_01.png" ... '); tic (); print ('-dpng', 'ezcontour_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezcontour_01.png" already exists.\n'); end catch fprintf ('ERROR in ezcontour_01: %s\n', lasterr ()); err_fid = fopen ('ezcontour_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezcontourf_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); f = @(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2); ezcontourf (f, [-3, 3]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezcontourf_01.png" ... '); tic (); print ('-dpng', 'ezcontourf_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezcontourf_01.png" already exists.\n'); end catch fprintf ('ERROR in ezcontourf_01: %s\n', lasterr ()); err_fid = fopen ('ezcontourf_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezmesh_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); f = @(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2); ezmesh (f, [-3, 3]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezmesh_01.png" ... '); tic (); print ('-dpng', 'ezmesh_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezmesh_01.png" already exists.\n'); end catch fprintf ('ERROR in ezmesh_01: %s\n', lasterr ()); err_fid = fopen ('ezmesh_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezmesh_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); fx = @(s,t) cos (s) .* cos (t); fy = @(s,t) sin (s) .* cos (t); fz = @(s,t) sin (t); ezmesh (fx, fy, fz, [-pi,pi,-pi/2,pi/2], 20); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezmesh_02.png" ... '); tic (); print ('-dpng', 'ezmesh_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezmesh_02.png" already exists.\n'); end catch fprintf ('ERROR in ezmesh_02: %s\n', lasterr ()); err_fid = fopen ('ezmesh_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezmeshc_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); f = @(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2); ezmeshc (f, [-3, 3]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezmeshc_01.png" ... '); tic (); print ('-dpng', 'ezmeshc_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezmeshc_01.png" already exists.\n'); end catch fprintf ('ERROR in ezmeshc_01: %s\n', lasterr ()); err_fid = fopen ('ezmeshc_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezplot_01.png', 'file')) rand ('seed', 1); tic (); %% sinc function using function handle f = @(x) sin (pi*x) ./ (pi*x); ezplot (f); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezplot_01.png" ... '); tic (); print ('-dpng', 'ezplot_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezplot_01.png" already exists.\n'); end catch fprintf ('ERROR in ezplot_01: %s\n', lasterr ()); err_fid = fopen ('ezplot_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezplot_02.png', 'file')) rand ('seed', 1); tic (); %% example of a function string and explicit limits clf; ezplot ('1/x', [-2 2]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezplot_02.png" ... '); tic (); print ('-dpng', 'ezplot_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezplot_02.png" already exists.\n'); end catch fprintf ('ERROR in ezplot_02: %s\n', lasterr ()); err_fid = fopen ('ezplot_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezplot_03.png', 'file')) rand ('seed', 1); tic (); %% parameterized function example over -2*pi <= t <= +2*pi clf; ezplot (@cos, @sin); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezplot_03.png" ... '); tic (); print ('-dpng', 'ezplot_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezplot_03.png" already exists.\n'); end catch fprintf ('ERROR in ezplot_03: %s\n', lasterr ()); err_fid = fopen ('ezplot_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezplot_04.png', 'file')) rand ('seed', 1); tic (); %% implicit function of 2 variables clf; ezplot (inline ('x^2 - y^2 - 1')); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezplot_04.png" ... '); tic (); print ('-dpng', 'ezplot_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezplot_04.png" already exists.\n'); end catch fprintf ('ERROR in ezplot_04: %s\n', lasterr ()); err_fid = fopen ('ezplot_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezplot3_01.png', 'file')) rand ('seed', 1); tic (); clf; fx = @(t) cos (t); fy = @(t) sin (t); fz = @(t) t; ezplot3 (fx, fy, fz, [0, 10*pi], 100); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezplot3_01.png" ... '); tic (); print ('-dpng', 'ezplot3_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezplot3_01.png" already exists.\n'); end catch fprintf ('ERROR in ezplot3_01: %s\n', lasterr ()); err_fid = fopen ('ezplot3_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezplot3_02.png', 'file')) rand ('seed', 1); tic (); clf; fx = @(t) cos (t); fy = @(t) sin (t); fz = @(t) t; ezplot3 (fx, fy, fz, [0, 5*pi], 100, 'animate'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezplot3_02.png" ... '); tic (); print ('-dpng', 'ezplot3_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezplot3_02.png" already exists.\n'); end catch fprintf ('ERROR in ezplot3_02: %s\n', lasterr ()); err_fid = fopen ('ezplot3_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezpolar_01.png', 'file')) rand ('seed', 1); tic (); clf; ezpolar (@(t) sin (5/4 * t), [0, 8*pi]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezpolar_01.png" ... '); tic (); print ('-dpng', 'ezpolar_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezpolar_01.png" already exists.\n'); end catch fprintf ('ERROR in ezpolar_01: %s\n', lasterr ()); err_fid = fopen ('ezpolar_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezsurf_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); f = @(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2); ezsurf (f, [-3, 3]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezsurf_01.png" ... '); tic (); print ('-dpng', 'ezsurf_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezsurf_01.png" already exists.\n'); end catch fprintf ('ERROR in ezsurf_01: %s\n', lasterr ()); err_fid = fopen ('ezsurf_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezsurf_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); fx = @(s,t) cos (s) .* cos (t); fy = @(s,t) sin (s) .* cos (t); fz = @(s,t) sin (t); ezsurf (fx, fy, fz, [-pi,pi,-pi/2,pi/2], 20); axis equal; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezsurf_02.png" ... '); tic (); print ('-dpng', 'ezsurf_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezsurf_02.png" already exists.\n'); end catch fprintf ('ERROR in ezsurf_02: %s\n', lasterr ()); err_fid = fopen ('ezsurf_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezsurf_03.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); f = @(x,y) x.^2 + y.^2; subplot (1,2,1); ezsurf (f, [-2,2]); title ({'x^2 + y^2'; 'plotted over rectangular grid (default)'}); subplot (1,2,2); ezsurf (f, [-2,2], 'circ'); title ({'x^2 + y^2'; 'plotted over circular disk with "circ"'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezsurf_03.png" ... '); tic (); print ('-dpng', 'ezsurf_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezsurf_03.png" already exists.\n'); end catch fprintf ('ERROR in ezsurf_03: %s\n', lasterr ()); err_fid = fopen ('ezsurf_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ezsurfc_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); f = @(x,y) sqrt (abs (x .* y)) ./ (1 + x.^2 + y.^2); ezsurfc (f, [-3, 3]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ezsurfc_01.png" ... '); tic (); print ('-dpng', 'ezsurfc_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ezsurfc_01.png" already exists.\n'); end catch fprintf ('ERROR in ezsurfc_01: %s\n', lasterr ()); err_fid = fopen ('ezsurfc_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('feather_01.png', 'file')) rand ('seed', 1); tic (); clf; phi = [0 : 15 : 360] * pi/180; feather (sin (phi), cos (phi)); axis tight; title ('feather plot'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "feather_01.png" ... '); tic (); print ('-dpng', 'feather_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "feather_01.png" already exists.\n'); end catch fprintf ('ERROR in feather_01: %s\n', lasterr ()); err_fid = fopen ('feather_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('fill_01.png', 'file')) rand ('seed', 1); tic (); clf; t1 = (1/16:1/8:1) * 2*pi; t2 = ((1/16:1/8:1) + 1/32) * 2*pi; x1 = sin (t1) - 0.8; y1 = cos (t1); x2 = sin (t2) + 0.8; y2 = cos (t2); h = fill (x1,y1,'r', x2,y2,'g'); title ({'fill() function'; 'cdata specified with string'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "fill_01.png" ... '); tic (); print ('-dpng', 'fill_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "fill_01.png" already exists.\n'); end catch fprintf ('ERROR in fill_01: %s\n', lasterr ()); err_fid = fopen ('fill_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('fill_02.png', 'file')) rand ('seed', 1); tic (); clf; t1 = (1/16:1/8:1) * 2*pi; t2 = ((1/16:1/8:1) + 1/32) * 2*pi; x1 = sin (t1) - 0.8; y1 = cos (t1); x2 = sin (t2) + 0.8; y2 = cos (t2); h = fill (x1,y1,1, x2,y2,2); title ({'fill() function'; 'cdata = row vector produces FaceColor = "flat"'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "fill_02.png" ... '); tic (); print ('-dpng', 'fill_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "fill_02.png" already exists.\n'); end catch fprintf ('ERROR in fill_02: %s\n', lasterr ()); err_fid = fopen ('fill_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('fill_03.png', 'file')) rand ('seed', 1); tic (); clf; x = [0 0 1 0.5 1 0.5 0 0]; y = [0 0 0 0 1 0.5 1 0.5]; c = [1 2 3 4]'; fill (x, y, c); title ({'fill() function'; 'cdata = column vector produces FaceColor = "interp"'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "fill_03.png" ... '); tic (); print ('-dpng', 'fill_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "fill_03.png" already exists.\n'); end catch fprintf ('ERROR in fill_03: %s\n', lasterr ()); err_fid = fopen ('fill_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('fplot_01.png', 'file')) rand ('seed', 1); tic (); clf; fplot (@cos, [0, 2*pi]); title ('fplot() single function'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "fplot_01.png" ... '); tic (); print ('-dpng', 'fplot_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "fplot_01.png" already exists.\n'); end catch fprintf ('ERROR in fplot_01: %s\n', lasterr ()); err_fid = fopen ('fplot_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('fplot_02.png', 'file')) rand ('seed', 1); tic (); clf; fplot ('[cos(x), sin(x)]', [0, 2*pi]); title ('fplot() multiple functions'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "fplot_02.png" ... '); tic (); print ('-dpng', 'fplot_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "fplot_02.png" already exists.\n'); end catch fprintf ('ERROR in fplot_02: %s\n', lasterr ()); err_fid = fopen ('fplot_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('fplot_03.png', 'file')) rand ('seed', 1); tic (); clf; %% sinc function fh = @(x) sin (pi*x) ./ (pi*x); fplot (fh, [-5, 5]); title ('fplot() sinc function'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "fplot_03.png" ... '); tic (); print ('-dpng', 'fplot_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "fplot_03.png" already exists.\n'); end catch fprintf ('ERROR in fplot_03: %s\n', lasterr ()); err_fid = fopen ('fplot_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('isosurface_01.png', 'file')) rand ('seed', 1); tic (); clf; [x,y,z] = meshgrid (-2:0.5:2, -2:0.5:2, -2:0.5:2); v = x.^2 + y.^2 + z.^2; isosurface (x, y, z, v, 1); axis equal; title ('isosurface of a sphere'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "isosurface_01.png" ... '); tic (); print ('-dpng', 'isosurface_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "isosurface_01.png" already exists.\n'); end catch fprintf ('ERROR in isosurface_01: %s\n', lasterr ()); err_fid = fopen ('isosurface_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('line_01.png', 'file')) rand ('seed', 1); tic (); clf line ([0 1], [0.8 0.8], 'linestyle', '-', 'color', 'b'); line ([0 1], [0.6 0.6], 'linestyle', '--', 'color', 'g'); line ([0 1], [0.4 0.4], 'linestyle', ':', 'color', 'r'); line ([0 1], [0.2 0.2], 'linestyle', '-.', 'color', 'k'); ylim ([0 1]); title ('line() with various linestyles'); legend ('"-"', '"--"', '":"', '"-."', 'location', 'eastoutside'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "line_01.png" ... '); tic (); print ('-dpng', 'line_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "line_01.png" already exists.\n'); end catch fprintf ('ERROR in line_01: %s\n', lasterr ()); err_fid = fopen ('line_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('line_02.png', 'file')) rand ('seed', 1); tic (); clf x = 0:0.3:10; y1 = cos (x); y2 = sin (x); subplot (3,1,1); args = {'color', 'b', 'marker', 's'}; line ([x(:), x(:)], [y1(:), y2(:)], args{:}); title ('Test broadcasting for line()'); subplot (3,1,2); line (x(:), [y1(:), y2(:)], args{:}); subplot (3,1,3); line ([x(:), x(:)+pi/2], y1(:), args{:}); xlim ([0 10]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "line_02.png" ... '); tic (); print ('-dpng', 'line_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "line_02.png" already exists.\n'); end catch fprintf ('ERROR in line_02: %s\n', lasterr ()); err_fid = fopen ('line_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('loglog_01.png', 'file')) rand ('seed', 1); tic (); clf; t = 1:0.01:10; x = sort ((t .* (1 + rand (size (t)))) .^ 2); y = (t .* (1 + rand (size (t)))) .^ 2; loglog (x, y); title ({'loglog() plot', 'Both axes are logarithmic'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "loglog_01.png" ... '); tic (); print ('-dpng', 'loglog_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "loglog_01.png" already exists.\n'); end catch fprintf ('ERROR in loglog_01: %s\n', lasterr ()); err_fid = fopen ('loglog_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('loglog_02.png', 'file')) rand ('seed', 1); tic (); clf; a = logspace (-5, 1, 10); b =-logspace (-5, 1, 10); subplot (1,2,1); loglog (a, b); xlabel ('loglog (a, b)'); subplot (1,2,2); loglog (a, abs (b)); set (gca, 'ydir', 'reverse'); xlabel ('loglog (a, abs (b))'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "loglog_02.png" ... '); tic (); print ('-dpng', 'loglog_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "loglog_02.png" already exists.\n'); end catch fprintf ('ERROR in loglog_02: %s\n', lasterr ()); err_fid = fopen ('loglog_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('loglogerr_01.png', 'file')) rand ('seed', 1); tic (); clf; x = exp (log (0.01):0.2:log (10)); y = wblpdf (x, 3, 2); eyu = 2*rand (size (y)) .* y; eyl = 0.5*rand (size (y)) .* y; loglogerr (x, y, eyl, eyu, '#~x-'); xlim (x([1, end])); title ({'loglogerr(): loglog() plot with errorbars', ... 'Both axes are logarithmic'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "loglogerr_01.png" ... '); tic (); print ('-dpng', 'loglogerr_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "loglogerr_01.png" already exists.\n'); end catch fprintf ('ERROR in loglogerr_01: %s\n', lasterr ()); err_fid = fopen ('loglogerr_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('mesh_01.png', 'file')) rand ('seed', 1); tic (); clf; x = logspace (0,1,11); z = x'*x; mesh (x, x, z); xlabel 'X-axis'; ylabel 'Y-axis'; zlabel 'Z-axis'; title ('mesh() with color proportional to height'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "mesh_01.png" ... '); tic (); print ('-dpng', 'mesh_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "mesh_01.png" already exists.\n'); end catch fprintf ('ERROR in mesh_01: %s\n', lasterr ()); err_fid = fopen ('mesh_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('mesh_02.png', 'file')) rand ('seed', 1); tic (); clf; x = logspace (0,1,11); z = x'*x; mesh (x, x, z, z.^2); xlabel 'X-axis'; ylabel 'Y-axis'; zlabel 'linear scale'; title ('mesh() with color proportional to Z^2'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "mesh_02.png" ... '); tic (); print ('-dpng', 'mesh_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "mesh_02.png" already exists.\n'); end catch fprintf ('ERROR in mesh_02: %s\n', lasterr ()); err_fid = fopen ('mesh_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('mesh_03.png', 'file')) rand ('seed', 1); tic (); clf; x = logspace (0,1,11); z = x'*x; mesh (x, x, z, z.^2); set (gca, 'zscale', 'log'); xlabel 'X-axis'; ylabel 'Y-axis'; zlabel 'log scale'; title ({'mesh() with color proportional to Z^2', 'Z-axis is log scale'}); try if (strcmp (get (gcf, '__graphics_toolkit__'), 'gnuplot')) title ({'Gnuplot: mesh color is wrong', 'This is a Gnuplot bug'}); end catch end t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "mesh_03.png" ... '); tic (); print ('-dpng', 'mesh_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "mesh_03.png" already exists.\n'); end catch fprintf ('ERROR in mesh_03: %s\n', lasterr ()); err_fid = fopen ('mesh_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('mesh_04.png', 'file')) rand ('seed', 1); tic (); clf; x = logspace (0,1,11); z = x'*x; mesh (x, x, z, 'facecolor', 'none', 'edgecolor', 'c'); xlabel 'X-axis'; ylabel 'Y-axis'; zlabel 'Z-axis'; title ({'mesh() default properties overridden', ... 'transparent mesh with cyan color'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "mesh_04.png" ... '); tic (); print ('-dpng', 'mesh_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "mesh_04.png" already exists.\n'); end catch fprintf ('ERROR in mesh_04: %s\n', lasterr ()); err_fid = fopen ('mesh_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('meshc_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [X, Y] = meshgrid (linspace (-3, 3, 40)); Z = sqrt (abs (X .* Y)) ./ (1 + X.^2 + Y.^2); meshc (X, Y, Z); title ('meshc() combines mesh/contour plots'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "meshc_01.png" ... '); tic (); print ('-dpng', 'meshc_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "meshc_01.png" already exists.\n'); end catch fprintf ('ERROR in meshc_01: %s\n', lasterr ()); err_fid = fopen ('meshc_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('meshz_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); Z = peaks (); meshz (Z); title ('meshz() plot of peaks() function'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "meshz_01.png" ... '); tic (); print ('-dpng', 'meshz_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "meshz_01.png" already exists.\n'); end catch fprintf ('ERROR in meshz_01: %s\n', lasterr ()); err_fid = fopen ('meshz_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('meshz_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); Z = peaks (); subplot (1,2,1) mesh (Z); daspect ([2.5, 2.5, 1]); title ('mesh() plot'); subplot (1,2,2) meshz (Z); daspect ([2.5, 2.5, 1]); title ('meshz() plot'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "meshz_02.png" ... '); tic (); print ('-dpng', 'meshz_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "meshz_02.png" already exists.\n'); end catch fprintf ('ERROR in meshz_02: %s\n', lasterr ()); err_fid = fopen ('meshz_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('meshz_03.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [X,Y,Z] = peaks (); [fx, fy] = gradient (Z); C = sqrt (fx.^2 + fy.^2); meshz (X,Y,Z,C); title ('meshz() plot with color determined by gradient'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "meshz_03.png" ... '); tic (); print ('-dpng', 'meshz_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "meshz_03.png" already exists.\n'); end catch fprintf ('ERROR in meshz_03: %s\n', lasterr ()); err_fid = fopen ('meshz_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('pareto_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap (jet (64)); Cheese = {'Cheddar', 'Swiss', 'Camembert', 'Munster', 'Stilton', 'Blue'}; Sold = [105, 30, 70, 10, 15, 20]; pareto (Sold, Cheese); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "pareto_01.png" ... '); tic (); print ('-dpng', 'pareto_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "pareto_01.png" already exists.\n'); end catch fprintf ('ERROR in pareto_01: %s\n', lasterr ()); err_fid = fopen ('pareto_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('pareto_02.png', 'file')) rand ('seed', 1); tic (); clf; % Suppose that we want establish which products makes 80% of turnover. Codes = {'AB4','BD7','CF8','CC5','AD11','BB5','BB3','AD8','DF3','DE7'}; Value = [2.35 7.9 2.45 1.1 0.15 13.45 5.4 2.05 0.85 1.65]'; SoldUnits = [54723 41114 16939 1576091 168000 687197 120222 168195, ... 1084118 55576]'; pareto (Value.*SoldUnits, Codes); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "pareto_02.png" ... '); tic (); print ('-dpng', 'pareto_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "pareto_02.png" already exists.\n'); end catch fprintf ('ERROR in pareto_02: %s\n', lasterr ()); err_fid = fopen ('pareto_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('patch_01.png', 'file')) rand ('seed', 1); tic (); %% Patches with same number of vertices clf; t1 = (1/16:1/8:1)' * 2*pi; t2 = ((1/16:1/8:1)' + 1/32) * 2*pi; x1 = sin (t1) - 0.8; y1 = cos (t1); x2 = sin (t2) + 0.8; y2 = cos (t2); patch ([x1,x2], [y1,y2], 'r'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "patch_01.png" ... '); tic (); print ('-dpng', 'patch_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "patch_01.png" already exists.\n'); end catch fprintf ('ERROR in patch_01: %s\n', lasterr ()); err_fid = fopen ('patch_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('patch_02.png', 'file')) rand ('seed', 1); tic (); %% Unclosed patch clf; t1 = (1/16:1/8:1)' * 2*pi; t2 = ((1/16:1/16:1)' + 1/32) * 2*pi; x1 = sin (t1) - 0.8; y1 = cos (t1); x2 = sin (t2) + 0.8; y2 = cos (t2); patch ([[x1;NaN(8,1)],x2], [[y1;NaN(8,1)],y2], 'r'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "patch_02.png" ... '); tic (); print ('-dpng', 'patch_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "patch_02.png" already exists.\n'); end catch fprintf ('ERROR in patch_02: %s\n', lasterr ()); err_fid = fopen ('patch_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('patch_03.png', 'file')) rand ('seed', 1); tic (); %% Specify vertices and faces separately clf; t1 = (1/16:1/8:1)' * 2*pi; t2 = ((1/16:1/16:1)' + 1/32) * 2*pi; x1 = sin (t1) - 0.8; y1 = cos (t1); x2 = sin (t2) + 0.8; y2 = cos (t2); vert = [x1, y1; x2, y2]; fac = [1:8,NaN(1,8);9:24]; patch ('Faces',fac, 'Vertices',vert, 'FaceColor','r'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "patch_03.png" ... '); tic (); print ('-dpng', 'patch_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "patch_03.png" already exists.\n'); end catch fprintf ('ERROR in patch_03: %s\n', lasterr ()); err_fid = fopen ('patch_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('patch_04.png', 'file')) rand ('seed', 1); tic (); %% Specify vertices and faces separately clf; t1 = (1/16:1/8:1)' * 2*pi; t2 = ((1/16:1/16:1)' + 1/32) * 2*pi; x1 = sin (t1) - 0.8; y1 = cos (t1); x2 = sin (t2) + 0.8; y2 = cos (t2); vert = [x1, y1; x2, y2]; fac = [1:8,NaN(1,8);9:24]; patch ('Faces',fac, 'Vertices',vert, ... 'FaceVertexCData',[0, 1, 0; 0, 0, 1], 'FaceColor', 'flat'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "patch_04.png" ... '); tic (); print ('-dpng', 'patch_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "patch_04.png" already exists.\n'); end catch fprintf ('ERROR in patch_04: %s\n', lasterr ()); err_fid = fopen ('patch_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('patch_05.png', 'file')) rand ('seed', 1); tic (); %% Property change on multiple patches clf; t1 = (1/16:1/8:1)' * 2*pi; t2 = ((1/16:1/8:1)' + 1/32) * 2*pi; x1 = sin (t1) - 0.8; y1 = cos (t1); x2 = sin (t2) + 0.8; y2 = cos (t2); h = patch ([x1,x2], [y1,y2], cat (3, [0,0],[1,0],[0,1])); pause (1); set (h, 'FaceColor', 'r'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "patch_05.png" ... '); tic (); print ('-dpng', 'patch_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "patch_05.png" already exists.\n'); end catch fprintf ('ERROR in patch_05: %s\n', lasterr ()); err_fid = fopen ('patch_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('patch_06.png', 'file')) rand ('seed', 1); tic (); clf; vertices = [0, 0, 0; 1, 0, 0; 1, 1, 0; 0, 1, 0; 0.5, 0.5, 1]; faces = [1, 2, 5; 2, 3, 5; 3, 4, 5; 4, 1, 5]; patch ('Vertices', vertices, 'Faces', faces, ... 'FaceVertexCData', jet (4), 'FaceColor', 'flat'); view (-37.5, 30); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "patch_06.png" ... '); tic (); print ('-dpng', 'patch_06.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "patch_06.png" already exists.\n'); end catch fprintf ('ERROR in patch_06: %s\n', lasterr ()); err_fid = fopen ('patch_06.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('patch_07.png', 'file')) rand ('seed', 1); tic (); clf; vertices = [0, 0, 0; 1, 0, 0; 1, 1, 0; 0, 1, 0; 0.5, 0.5, 1]; faces = [1, 2, 5; 2, 3, 5; 3, 4, 5; 4, 1, 5]; patch ('Vertices', vertices, 'Faces', faces, ... 'FaceVertexCData', jet (5), 'FaceColor', 'interp'); view (-37.5, 30); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "patch_07.png" ... '); tic (); print ('-dpng', 'patch_07.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "patch_07.png" already exists.\n'); end catch fprintf ('ERROR in patch_07: %s\n', lasterr ()); err_fid = fopen ('patch_07.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('patch_08.png', 'file')) rand ('seed', 1); tic (); clf; colormap (jet (64)); x = [0 1 1 0]; y = [0 0 1 1]; subplot (2,1,1); title ('Blue, Light-Green, and Red Horizontal Bars'); patch (x, y + 0, 1); patch (x, y + 1, 2); patch (x, y + 2, 3); subplot (2,1,2); title ('Blue, Light-Green, and Red Vertical Bars'); patch (x + 0, y, 1 * ones (size (x))); patch (x + 1, y, 2 * ones (size (x))); patch (x + 2, y, 3 * ones (size (x))); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "patch_08.png" ... '); tic (); print ('-dpng', 'patch_08.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "patch_08.png" already exists.\n'); end catch fprintf ('ERROR in patch_08: %s\n', lasterr ()); err_fid = fopen ('patch_08.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('patch_09.png', 'file')) rand ('seed', 1); tic (); clf; colormap (jet (64)); x = [0 1 1 0]; y = [0 0 1 1]; subplot (2,1,1); title ('Blue horizontal bars: Dark to Light'); patch (x, y + 0, 1, 'cdatamapping', 'direct'); patch (x, y + 1, 9, 'cdatamapping', 'direct'); patch (x, y + 2, 17, 'cdatamapping', 'direct'); subplot (2,1,2); title ('Blue vertical bars: Dark to Light'); patch (x + 0, y, 1 * ones (size (x)), 'cdatamapping', 'direct'); patch (x + 1, y, 9 * ones (size (x)), 'cdatamapping', 'direct'); patch (x + 2, y, 17 * ones (size (x)), 'cdatamapping', 'direct'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "patch_09.png" ... '); tic (); print ('-dpng', 'patch_09.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "patch_09.png" already exists.\n'); end catch fprintf ('ERROR in patch_09: %s\n', lasterr ()); err_fid = fopen ('patch_09.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('patch_10.png', 'file')) rand ('seed', 1); tic (); clf; colormap (jet (64)); x = [ 0 0; 1 1; 1 0 ]; y = [ 0 0; 0 1; 1 1 ]; p = patch (x, y, 'b'); set (p, 'cdatamapping', 'direct', 'facecolor', 'flat', 'cdata', [1 32]); title ('Direct mapping of colors: Light-Green UL and Blue LR triangles'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "patch_10.png" ... '); tic (); print ('-dpng', 'patch_10.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "patch_10.png" already exists.\n'); end catch fprintf ('ERROR in patch_10: %s\n', lasterr ()); err_fid = fopen ('patch_10.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('patch_11.png', 'file')) rand ('seed', 1); tic (); clf; colormap (jet (64)); x = [ 0 0; 1 1; 1 0 ]; y = [ 0 0; 0 1; 1 1 ]; p = patch (x, y, [1 32]); title ('Autoscaling of colors: Red UL and Blue LR triangles'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "patch_11.png" ... '); tic (); print ('-dpng', 'patch_11.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "patch_11.png" already exists.\n'); end catch fprintf ('ERROR in patch_11: %s\n', lasterr ()); err_fid = fopen ('patch_11.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('pcolor_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); Z = peaks (); pcolor (Z); title ('pcolor() of peaks with facet shading'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "pcolor_01.png" ... '); tic (); print ('-dpng', 'pcolor_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "pcolor_01.png" already exists.\n'); end catch fprintf ('ERROR in pcolor_01: %s\n', lasterr ()); err_fid = fopen ('pcolor_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('pcolor_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [X,Y,Z] = sombrero (41); [Fx,Fy] = gradient (Z); pcolor (X,Y,Fx+Fy); shading interp; axis tight; title ('pcolor() of peaks with interp shading'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "pcolor_02.png" ... '); tic (); print ('-dpng', 'pcolor_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "pcolor_02.png" already exists.\n'); end catch fprintf ('ERROR in pcolor_02: %s\n', lasterr ()); err_fid = fopen ('pcolor_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('pie_01.png', 'file')) rand ('seed', 1); tic (); clf; pie ([3, 2, 1], [0, 0, 1]); colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); title ('pie() with exploded wedge'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "pie_01.png" ... '); tic (); print ('-dpng', 'pie_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "pie_01.png" already exists.\n'); end catch fprintf ('ERROR in pie_01: %s\n', lasterr ()); err_fid = fopen ('pie_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('pie_02.png', 'file')) rand ('seed', 1); tic (); clf; pie ([3, 2, 1], [0, 0, 1], {'Cheddar', 'Swiss', 'Camembert'}); colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); axis ([-2,2,-2,2]); title ('pie() with labels'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "pie_02.png" ... '); tic (); print ('-dpng', 'pie_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "pie_02.png" already exists.\n'); end catch fprintf ('ERROR in pie_02: %s\n', lasterr ()); err_fid = fopen ('pie_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('pie_03.png', 'file')) rand ('seed', 1); tic (); clf; pie ([0.17, 0.34, 0.41], {'Cheddar', 'Swiss', 'Camembert'}); colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); axis ([-2,2,-2,2]); title ('pie() with missing slice'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "pie_03.png" ... '); tic (); print ('-dpng', 'pie_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "pie_03.png" already exists.\n'); end catch fprintf ('ERROR in pie_03: %s\n', lasterr ()); err_fid = fopen ('pie_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('pie3_01.png', 'file')) rand ('seed', 1); tic (); clf; pie3 ([5:-1:1], [0, 0, 1, 0, 0]); colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); title ('pie3() with exploded wedge'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "pie3_01.png" ... '); tic (); print ('-dpng', 'pie3_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "pie3_01.png" already exists.\n'); end catch fprintf ('ERROR in pie3_01: %s\n', lasterr ()); err_fid = fopen ('pie3_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('pie3_02.png', 'file')) rand ('seed', 1); tic (); clf; pie3 ([3, 2, 1], [0, 0, 1], {'Cheddar', 'Swiss', 'Camembert'}); colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); axis ([-2,2,-2,2]); title ('pie3() with labels'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "pie3_02.png" ... '); tic (); print ('-dpng', 'pie3_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "pie3_02.png" already exists.\n'); end catch fprintf ('ERROR in pie3_02: %s\n', lasterr ()); err_fid = fopen ('pie3_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('pie3_03.png', 'file')) rand ('seed', 1); tic (); clf; pie3 ([0.17, 0.34, 0.41], {'Cheddar', 'Swiss', 'Camembert'}); colormap ([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); axis ([-2,2,-2,2]); title ('pie3() with missing slice'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "pie3_03.png" ... '); tic (); print ('-dpng', 'pie3_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "pie3_03.png" already exists.\n'); end catch fprintf ('ERROR in pie3_03: %s\n', lasterr ()); err_fid = fopen ('pie3_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('plot_01.png', 'file')) rand ('seed', 1); tic (); x = 1:5; y = 1:5; plot (x,y,'g'); title ('plot() of green line at 45 degrees'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "plot_01.png" ... '); tic (); print ('-dpng', 'plot_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "plot_01.png" already exists.\n'); end catch fprintf ('ERROR in plot_01: %s\n', lasterr ()); err_fid = fopen ('plot_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('plot_02.png', 'file')) rand ('seed', 1); tic (); x = 1:5; y = 1:5; plot (x,y,'g*'); title ('plot() of green stars along a line at 45 degrees'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "plot_02.png" ... '); tic (); print ('-dpng', 'plot_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "plot_02.png" already exists.\n'); end catch fprintf ('ERROR in plot_02: %s\n', lasterr ()); err_fid = fopen ('plot_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('plot_03.png', 'file')) rand ('seed', 1); tic (); x1 = 1:5; y1 = 1:5; x2 = 5:9; y2 = 5:-1:1; plot (x1,y1,'bo-', x2,y2,'rs-'); axis ('tight'); title ({'plot() of blue circles ascending and red squares descending'; 'connecting lines drawn'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "plot_03.png" ... '); tic (); print ('-dpng', 'plot_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "plot_03.png" already exists.\n'); end catch fprintf ('ERROR in plot_03: %s\n', lasterr ()); err_fid = fopen ('plot_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('plot_04.png', 'file')) rand ('seed', 1); tic (); x = 0:10; plot (x, rand (numel (x), 3)) axis ([0 10 0 1]) title ({'Three random variables', 'x[1x11], y[11x3]'}) t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "plot_04.png" ... '); tic (); print ('-dpng', 'plot_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "plot_04.png" already exists.\n'); end catch fprintf ('ERROR in plot_04: %s\n', lasterr ()); err_fid = fopen ('plot_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('plot_05.png', 'file')) rand ('seed', 1); tic (); x = 0:10; plot (x, rand (3, numel (x))) axis ([0 10 0 1]) title ({'Three random variables', 'x[1x11], y[3x11]'}) t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "plot_05.png" ... '); tic (); print ('-dpng', 'plot_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "plot_05.png" already exists.\n'); end catch fprintf ('ERROR in plot_05: %s\n', lasterr ()); err_fid = fopen ('plot_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('plot_06.png', 'file')) rand ('seed', 1); tic (); x = 0:10; plot (repmat (x, 2, 1), rand (2, numel (x)), '-s') axis ([0 10 0 1]) title ({'Vertical lines with random height and lengths', ... 'x[2x11], y[2,11]'}) t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "plot_06.png" ... '); tic (); print ('-dpng', 'plot_06.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "plot_06.png" already exists.\n'); end catch fprintf ('ERROR in plot_06: %s\n', lasterr ()); err_fid = fopen ('plot_06.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('plot_07.png', 'file')) rand ('seed', 1); tic (); x = 0:10; plot (repmat (x(:), 1, 2), rand (numel (x), 2)) axis ([0 10 0 1]) title ({'Two random variables', 'x[11x2], y[11x2]'}) t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "plot_07.png" ... '); tic (); print ('-dpng', 'plot_07.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "plot_07.png" already exists.\n'); end catch fprintf ('ERROR in plot_07: %s\n', lasterr ()); err_fid = fopen ('plot_07.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('plot_08.png', 'file')) rand ('seed', 1); tic (); x = 0:10; shape = [1, 1, numel(x), 2]; x = reshape (repmat (x(:), 1, 2), shape); y = rand (shape); plot (x, y) axis ([0 10 0 1]) title ({'Two random variables', 'squeezed from 4-d arrays'}) t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "plot_08.png" ... '); tic (); print ('-dpng', 'plot_08.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "plot_08.png" already exists.\n'); end catch fprintf ('ERROR in plot_08: %s\n', lasterr ()); err_fid = fopen ('plot_08.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('plot3_01.png', 'file')) rand ('seed', 1); tic (); clf; z = [0:0.05:5]; plot3 (cos (2*pi*z), sin (2*pi*z), z) legend ('helix'); title ('plot3() of a helix'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "plot3_01.png" ... '); tic (); print ('-dpng', 'plot3_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "plot3_01.png" already exists.\n'); end catch fprintf ('ERROR in plot3_01: %s\n', lasterr ()); err_fid = fopen ('plot3_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('plot3_02.png', 'file')) rand ('seed', 1); tic (); clf; z = [0:0.05:5]; plot3 (z, exp (2i*pi*z)); legend ('complex sinusoid'); title ('plot3() with complex input'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "plot3_02.png" ... '); tic (); print ('-dpng', 'plot3_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "plot3_02.png" already exists.\n'); end catch fprintf ('ERROR in plot3_02: %s\n', lasterr ()); err_fid = fopen ('plot3_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('plotmatrix_01.png', 'file')) rand ('seed', 1); tic (); clf; plotmatrix (randn (100, 3), 'g+'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "plotmatrix_01.png" ... '); tic (); print ('-dpng', 'plotmatrix_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "plotmatrix_01.png" already exists.\n'); end catch fprintf ('ERROR in plotmatrix_01: %s\n', lasterr ()); err_fid = fopen ('plotmatrix_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('plotyy_01.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.1:2*pi; y1 = sin (x); y2 = exp (x - 1); ax = plotyy (x,y1, x-1,y2, @plot, @semilogy); xlabel ('X'); ylabel (ax(1), 'Axis 1'); ylabel (ax(2), 'Axis 2'); text (0.5, 0.5, 'Left Axis', ... 'color', [0 0 1], 'horizontalalignment', 'center', 'parent', ax(1)); text (4.5, 80, 'Right Axis', ... 'color', [0 0.5 0], 'horizontalalignment', 'center', 'parent', ax(2)); title ({'plotyy() example'; 'Left axis uses @plot, Right axis uses @semilogy'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "plotyy_01.png" ... '); tic (); print ('-dpng', 'plotyy_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "plotyy_01.png" already exists.\n'); end catch fprintf ('ERROR in plotyy_01: %s\n', lasterr ()); err_fid = fopen ('plotyy_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('plotyy_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); x = linspace (-1, 1, 201); subplot (2,2,1); plotyy (x,sin(pi*x), x,10*cos(pi*x)); subplot (2,2,2); surf (peaks (25)); subplot (2,2,3); contour (peaks (25)); subplot (2,2,4); plotyy (x,10*sin(2*pi*x), x,cos(2*pi*x)); axis square; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "plotyy_02.png" ... '); tic (); print ('-dpng', 'plotyy_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "plotyy_02.png" already exists.\n'); end catch fprintf ('ERROR in plotyy_02: %s\n', lasterr ()); err_fid = fopen ('plotyy_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('plotyy_03.png', 'file')) rand ('seed', 1); tic (); clf hold on t = (0:0.1:9); x = sin (t); y = 5 * cos (t); [hax, h1, h2] = plotyy (t, x, t, y); [~, h3, h4] = plotyy (t+1, x, t+1, y); set ([h3, h4], 'linestyle', '--'); xlabel (hax(1), 'xlabel'); title (hax(2), 'Two plotyy graphs on same figure using "hold on"'); ylabel (hax(1), 'Left axis is Blue'); ylabel (hax(2), 'Right axis is Green'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "plotyy_03.png" ... '); tic (); print ('-dpng', 'plotyy_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "plotyy_03.png" already exists.\n'); end catch fprintf ('ERROR in plotyy_03: %s\n', lasterr ()); err_fid = fopen ('plotyy_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('polar_01.png', 'file')) rand ('seed', 1); tic (); clf; theta = linspace (0,2*pi,1000); rho = sin (7*theta); polar (theta, rho); title ('polar() plot'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "polar_01.png" ... '); tic (); print ('-dpng', 'polar_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "polar_01.png" already exists.\n'); end catch fprintf ('ERROR in polar_01: %s\n', lasterr ()); err_fid = fopen ('polar_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('polar_02.png', 'file')) rand ('seed', 1); tic (); clf; theta = linspace (0,2*pi,1000); cplx = theta + i*sin (7*theta); polar (cplx, 'g'); title ('polar() plot of complex data'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "polar_02.png" ... '); tic (); print ('-dpng', 'polar_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "polar_02.png" already exists.\n'); end catch fprintf ('ERROR in polar_02: %s\n', lasterr ()); err_fid = fopen ('polar_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('polar_03.png', 'file')) rand ('seed', 1); tic (); clf; theta = linspace (0,2*pi,1000); rho = sin (2*theta).*cos (2*theta); polar (theta, rho, '--r'); set (gca, 'rtick', 0.1:0.1:0.6, 'ttick', 0:20:340); title ('polar() plot with finer grid'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "polar_03.png" ... '); tic (); print ('-dpng', 'polar_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "polar_03.png" already exists.\n'); end catch fprintf ('ERROR in polar_03: %s\n', lasterr ()); err_fid = fopen ('polar_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('polar_04.png', 'file')) rand ('seed', 1); tic (); clf; theta = linspace (0,2*pi,1000); rho = sin (2*theta).*cos (2*theta); polar (theta, rho, '--b'); set (gca, 'fontsize', 12, 'linewidth', 2, 'color', [0.8 0.8 0.8]); title ('polar() plot with modified axis appearance'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "polar_04.png" ... '); tic (); print ('-dpng', 'polar_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "polar_04.png" already exists.\n'); end catch fprintf ('ERROR in polar_04: %s\n', lasterr ()); err_fid = fopen ('polar_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('polar_05.png', 'file')) rand ('seed', 1); tic (); clf; theta = linspace (0,8*pi,1000); rho = sin (5/4*theta); polar (theta, rho); set (gca, 'rtick', 0.2:0.2:1); title ('polar() plot'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "polar_05.png" ... '); tic (); print ('-dpng', 'polar_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "polar_05.png" already exists.\n'); end catch fprintf ('ERROR in polar_05: %s\n', lasterr ()); err_fid = fopen ('polar_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('quiver_01.png', 'file')) rand ('seed', 1); tic (); clf; [x,y] = meshgrid (1:2:20); h = quiver (x,y, sin (2*pi*x/10), sin (2*pi*y/10)); title ('quiver plot') t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "quiver_01.png" ... '); tic (); print ('-dpng', 'quiver_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "quiver_01.png" already exists.\n'); end catch fprintf ('ERROR in quiver_01: %s\n', lasterr ()); err_fid = fopen ('quiver_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('quiver_02.png', 'file')) rand ('seed', 1); tic (); clf; x = linspace (0, 3, 80); y = sin (2*pi*x); theta = 2*pi*x + pi/2; quiver (x, y, sin (theta)/10, cos (theta)/10, 0.4); axis equal tight; hold on; plot (x,y,'r'); hold off; title ('quiver() with scaled arrows'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "quiver_02.png" ... '); tic (); print ('-dpng', 'quiver_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "quiver_02.png" already exists.\n'); end catch fprintf ('ERROR in quiver_02: %s\n', lasterr ()); err_fid = fopen ('quiver_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('quiver3_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [x, y, z] = peaks (25); surf (x, y, z); hold on; [u, v, w] = surfnorm (x, y, z / 10); h = quiver3 (x, y, z, u, v, w); set (h, 'maxheadsize', 0.25); hold off; title ('quiver3 of surface normals to peaks() function'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "quiver3_01.png" ... '); tic (); print ('-dpng', 'quiver3_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "quiver3_01.png" already exists.\n'); end catch fprintf ('ERROR in quiver3_01: %s\n', lasterr ()); err_fid = fopen ('quiver3_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('quiver3_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [x, y, z] = peaks (25); surf (x, y, z); hold on; [u, v, w] = surfnorm (x, y, z / 10); h = quiver3 (x, y, z, u, v, w); set (h, 'maxheadsize', 0.25); hold off; shading interp; title ({'quiver3 of surface normals to peaks() function'; ... 'shading "interp"'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "quiver3_02.png" ... '); tic (); print ('-dpng', 'quiver3_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "quiver3_02.png" already exists.\n'); end catch fprintf ('ERROR in quiver3_02: %s\n', lasterr ()); err_fid = fopen ('quiver3_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('rectangle_01.png', 'file')) rand ('seed', 1); tic (); clf; axis equal; rectangle ('Position', [0.05, 0.05, 0.9, 0.9], 'Curvature', [0.5, 0.5]); title ('rectangle() with corners curved'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "rectangle_01.png" ... '); tic (); print ('-dpng', 'rectangle_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "rectangle_01.png" already exists.\n'); end catch fprintf ('ERROR in rectangle_01: %s\n', lasterr ()); err_fid = fopen ('rectangle_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('rectangle_02.png', 'file')) rand ('seed', 1); tic (); clf; axis equal; rectangle ('Position', [0.05, 0.05, 0.9, 0.4], 'Curvature', 1.0); title ('rectangle() with sides as complete arcs'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "rectangle_02.png" ... '); tic (); print ('-dpng', 'rectangle_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "rectangle_02.png" already exists.\n'); end catch fprintf ('ERROR in rectangle_02: %s\n', lasterr ()); err_fid = fopen ('rectangle_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('rectangle_03.png', 'file')) rand ('seed', 1); tic (); clf; axis equal; h = rectangle ('Position', [0.05, 0.05, 0.9, 0.4], 'Curvature', 1.0); set (h, 'FaceColor', [0, 1, 0]); title ('rectangle() with FaceColor = green'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "rectangle_03.png" ... '); tic (); print ('-dpng', 'rectangle_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "rectangle_03.png" already exists.\n'); end catch fprintf ('ERROR in rectangle_03: %s\n', lasterr ()); err_fid = fopen ('rectangle_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ribbon_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [x, y, z] = sombrero (41); ribbon (y, z); title ('ribbon() plot of sombrero()'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ribbon_01.png" ... '); tic (); print ('-dpng', 'ribbon_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ribbon_01.png" already exists.\n'); end catch fprintf ('ERROR in ribbon_01: %s\n', lasterr ()); err_fid = fopen ('ribbon_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('rose_01.png', 'file')) rand ('seed', 1); tic (); clf; rose (2*randn (1e5, 1), 8); title ('rose() angular histogram plot with 8 bins'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "rose_01.png" ... '); tic (); print ('-dpng', 'rose_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "rose_01.png" already exists.\n'); end catch fprintf ('ERROR in rose_01: %s\n', lasterr ()); err_fid = fopen ('rose_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('rose_02.png', 'file')) rand ('seed', 1); tic (); clf; rose ([2*randn(1e5, 1), pi + 2*randn(1e5, 1)]); title ('rose() angular histogram plot with 2 data series'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "rose_02.png" ... '); tic (); print ('-dpng', 'rose_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "rose_02.png" already exists.\n'); end catch fprintf ('ERROR in rose_02: %s\n', lasterr ()); err_fid = fopen ('rose_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('scatter_01.png', 'file')) rand ('seed', 1); tic (); clf; x = randn (100, 1); y = randn (100, 1); scatter (x, y, 'r'); title ('scatter() plot with red bubbles'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "scatter_01.png" ... '); tic (); print ('-dpng', 'scatter_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "scatter_01.png" already exists.\n'); end catch fprintf ('ERROR in scatter_01: %s\n', lasterr ()); err_fid = fopen ('scatter_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('scatter_02.png', 'file')) rand ('seed', 1); tic (); clf; x = randn (100, 1); y = randn (100, 1); c = x .* y; scatter (x, y, 20, c, 'filled'); title ('scatter() with colored filled bubbles'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "scatter_02.png" ... '); tic (); print ('-dpng', 'scatter_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "scatter_02.png" already exists.\n'); end catch fprintf ('ERROR in scatter_02: %s\n', lasterr ()); err_fid = fopen ('scatter_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('scatter_03.png', 'file')) rand ('seed', 1); tic (); clf; x = randn (100, 1); y = randn (100, 1); scatter (x, y, [], sqrt (x.^2 + y.^2)); title ({'scatter() plot'; ... 'bubble color determined by distance from origin'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "scatter_03.png" ... '); tic (); print ('-dpng', 'scatter_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "scatter_03.png" already exists.\n'); end catch fprintf ('ERROR in scatter_03: %s\n', lasterr ()); err_fid = fopen ('scatter_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('scatter_04.png', 'file')) rand ('seed', 1); tic (); clf; rand_10x1_data5 = [0.777753, 0.093848, 0.183162, 0.399499, 0.337997, 0.686724, 0.073906, 0.651808, 0.869273, 0.137949]; rand_10x1_data6 = [0.37460, 0.25027, 0.19510, 0.51182, 0.54704, 0.56087, 0.24853, 0.75443, 0.42712, 0.44273]; x = rand_10x1_data5; y = rand_10x1_data6; s = 10 - 10*log (x.^2 + y.^2); h = scatter (x, y, [], 'r', 's'); title ({'scatter() plot'; ... 'marker is square, color is red'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "scatter_04.png" ... '); tic (); print ('-dpng', 'scatter_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "scatter_04.png" already exists.\n'); end catch fprintf ('ERROR in scatter_04: %s\n', lasterr ()); err_fid = fopen ('scatter_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('scatter_05.png', 'file')) rand ('seed', 1); tic (); clf; rand_10x1_data3 = [0.42262, 0.51623, 0.65992, 0.14999, 0.68385, 0.55929, 0.52251, 0.92204, 0.19762, 0.93726]; rand_10x1_data4 = [0.020207, 0.527193, 0.443472, 0.061683, 0.370277, 0.947349, 0.249591, 0.666304, 0.134247, 0.920356]; x = rand_10x1_data3; y = rand_10x1_data4; s = 10 - 10*log (x.^2 + y.^2); h = scatter (x, y, [], 'r', 's', 'filled'); title ({'scatter() plot'; ... 'marker is square, marker is filled, color is red'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "scatter_05.png" ... '); tic (); print ('-dpng', 'scatter_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "scatter_05.png" already exists.\n'); end catch fprintf ('ERROR in scatter_05: %s\n', lasterr ()); err_fid = fopen ('scatter_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('scatter_06.png', 'file')) rand ('seed', 1); tic (); clf; rand_10x1_data1 = [0.171577, 0.404796, 0.025469, 0.335309, 0.047814, 0.898480, 0.639599, 0.700247, 0.497798, 0.737940]; rand_10x1_data2 = [0.75495, 0.83991, 0.80850, 0.73603, 0.19360, 0.72573, 0.69371, 0.74388, 0.13837, 0.54143]; x = rand_10x1_data1; y = rand_10x1_data2; s = 10 - 10*log (x.^2 + y.^2); h = scatter (x, y, s, s, 's', 'filled'); title ({'scatter() plot with filled square markers', ... 'size and color of markers determined by algorithm'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "scatter_06.png" ... '); tic (); print ('-dpng', 'scatter_06.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "scatter_06.png" already exists.\n'); end catch fprintf ('ERROR in scatter_06: %s\n', lasterr ()); err_fid = fopen ('scatter_06.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('scatter_07.png', 'file')) rand ('seed', 1); tic (); clf; k = 1; for m = [1, 3] for n = [101, 50, 1] x = rand (n, 1); y = rand (n, 1); if (m > 1) str = 'Three Colors'; idx = ceil (rand (n, 1) * 3); colors = eye (3); colors = colors(idx, :); else str = 'Random Colors'; colors = rand (n, m); end if (n == 1) str = sprintf ('%s: 1 point', str); elseif (n < 100) str = sprintf ('%s: < 100 points', str); else str = sprintf ('%s: > 100 points', str); end subplot (2,3,k); k = k + 1; scatter (x, y, 15, colors, 'filled'); axis ([0 1 0 1]); title (str); end end t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "scatter_07.png" ... '); tic (); print ('-dpng', 'scatter_07.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "scatter_07.png" already exists.\n'); end catch fprintf ('ERROR in scatter_07: %s\n', lasterr ()); err_fid = fopen ('scatter_07.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('scatter_08.png', 'file')) rand ('seed', 1); tic (); clf; k = 1; for m = [1, 3] for n = [101, 50, 1] x = rand (n, 1); y = rand (n, 1); if (m > 1) str = 'Three Colors'; idx = ceil (rand (n, 1) * 3); colors = eye (3); colors = colors(idx, :); else str = 'Random Colors'; colors = rand (n, m); end if (n == 1) str = sprintf ('%s: 1 point', str); elseif (n < 100) str = sprintf ('%s: < 100 points', str); else str = sprintf ('%s: > 100 points', str); end subplot (2,3,k); k = k + 1; scatter (x, y, 15, colors); axis ([0 1 0 1]); title (str); end end t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "scatter_08.png" ... '); tic (); print ('-dpng', 'scatter_08.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "scatter_08.png" already exists.\n'); end catch fprintf ('ERROR in scatter_08: %s\n', lasterr ()); err_fid = fopen ('scatter_08.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('scatter3_01.png', 'file')) rand ('seed', 1); tic (); clf; [x, y, z] = peaks (20); scatter3 (x(:), y(:), z(:), [], z(:)); title ({'Default scatter3() plot', ... 'constant size bubbles and color determined by Z'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "scatter3_01.png" ... '); tic (); print ('-dpng', 'scatter3_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "scatter3_01.png" already exists.\n'); end catch fprintf ('ERROR in scatter3_01: %s\n', lasterr ()); err_fid = fopen ('scatter3_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('scatter3_02.png', 'file')) rand ('seed', 1); tic (); clf; x = rand (20,1); y = rand (20,1); z = rand (20,1); scatter3 (x(:), y(:), z(:), 10, z(:), 's'); title ({'scatter3() plot', ... 'marker is square, size is 10, color determined by Z'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "scatter3_02.png" ... '); tic (); print ('-dpng', 'scatter3_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "scatter3_02.png" already exists.\n'); end catch fprintf ('ERROR in scatter3_02: %s\n', lasterr ()); err_fid = fopen ('scatter3_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('scatter3_03.png', 'file')) rand ('seed', 1); tic (); clf; x = rand (20,1); y = rand (20,1); z = rand (20,1); scatter3 (x(:), y(:), z(:), 20*z(:), [], 's'); title ({'scatter3() plot', ... 'marker is square, size is determined by Z'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "scatter3_03.png" ... '); tic (); print ('-dpng', 'scatter3_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "scatter3_03.png" already exists.\n'); end catch fprintf ('ERROR in scatter3_03: %s\n', lasterr ()); err_fid = fopen ('scatter3_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('scatter3_04.png', 'file')) rand ('seed', 1); tic (); clf; x = rand (20,1); y = rand (20,1); z = rand (20,1); scatter3 (x(:), y(:), z(:), 20*z(:), z(:), 's'); title ({'scatter3() plot', ... 'marker is square, size and color determined by Z'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "scatter3_04.png" ... '); tic (); print ('-dpng', 'scatter3_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "scatter3_04.png" already exists.\n'); end catch fprintf ('ERROR in scatter3_04: %s\n', lasterr ()); err_fid = fopen ('scatter3_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('semilogx_01.png', 'file')) rand ('seed', 1); tic (); clf; x = 1:0.01:10; y = (x .* (1 + rand (size (x)))) .^ 2; semilogx (y, x); title ({'semilogx() plot', 'X-axis is logarithmic'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "semilogx_01.png" ... '); tic (); print ('-dpng', 'semilogx_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "semilogx_01.png" already exists.\n'); end catch fprintf ('ERROR in semilogx_01: %s\n', lasterr ()); err_fid = fopen ('semilogx_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('semilogx_02.png', 'file')) rand ('seed', 1); tic (); clf; x = logspace (-5, 1, 10); y = logspace (-5, 1, 10); subplot (1,2,1); semilogx (x, y); xlabel ('semilogx (x, y)'); subplot (1,2,2); semilogx (-x, y); xlabel ('semilogx (-x, y)'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "semilogx_02.png" ... '); tic (); print ('-dpng', 'semilogx_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "semilogx_02.png" already exists.\n'); end catch fprintf ('ERROR in semilogx_02: %s\n', lasterr ()); err_fid = fopen ('semilogx_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('semilogx_03.png', 'file')) rand ('seed', 1); tic (); clf; x = logspace (-5, 1, 10); y = logspace (-5, 1, 10); subplot (1,2,1); semilogx (x, y); set (gca, 'xdir', 'reverse', 'activepositionproperty', 'outerposition'); xlabel ({'semilogx (x, y)', 'xdir = reversed'}); subplot (1,2,2); semilogx (-x, y); set (gca, 'xdir', 'reverse', 'activepositionproperty', 'outerposition'); xlabel ({'semilogx (-x, y)', 'xdir = reversed'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "semilogx_03.png" ... '); tic (); print ('-dpng', 'semilogx_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "semilogx_03.png" already exists.\n'); end catch fprintf ('ERROR in semilogx_03: %s\n', lasterr ()); err_fid = fopen ('semilogx_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('semilogxerr_01.png', 'file')) rand ('seed', 1); tic (); clf; x = exp (log (0.01):0.2:log (10)); y = wblpdf (x, 2, 2); ey = 0.5*rand (size (y)) .* y; semilogxerr (x, y, ey, '#~x-'); xlim (x([1, end])); title ({'semilogxerr(): semilogx() plot with errorbars', ... 'X-axis is logarithmic'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "semilogxerr_01.png" ... '); tic (); print ('-dpng', 'semilogxerr_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "semilogxerr_01.png" already exists.\n'); end catch fprintf ('ERROR in semilogxerr_01: %s\n', lasterr ()); err_fid = fopen ('semilogxerr_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('semilogy_01.png', 'file')) rand ('seed', 1); tic (); clf; x = 1:0.01:10; y = (x .* (1 + rand (size (x)))) .^ 2; semilogy (x, y); title ({'semilogx() plot', 'Y-axis is logarithmic'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "semilogy_01.png" ... '); tic (); print ('-dpng', 'semilogy_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "semilogy_01.png" already exists.\n'); end catch fprintf ('ERROR in semilogy_01: %s\n', lasterr ()); err_fid = fopen ('semilogy_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('semilogy_02.png', 'file')) rand ('seed', 1); tic (); clf; x = logspace (-5, 1, 10); y = logspace (-5, 1, 10); subplot (2,1,1); semilogy (x, y); ylabel ('semilogy (x, y)'); subplot (2,1,2); semilogy (x, -y); ylabel ('semilogy (x, -y)'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "semilogy_02.png" ... '); tic (); print ('-dpng', 'semilogy_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "semilogy_02.png" already exists.\n'); end catch fprintf ('ERROR in semilogy_02: %s\n', lasterr ()); err_fid = fopen ('semilogy_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('semilogy_03.png', 'file')) rand ('seed', 1); tic (); clf; x = logspace (-5, 1, 10); y = logspace (-5, 1, 10); subplot (2,1,1); semilogy (x, y); set (gca, 'ydir', 'reverse', 'activepositionproperty', 'outerposition'); ylabel ({'semilogy (x, y)', 'ydir = reversed'}); subplot (2,1,2); semilogy (x, -y); set (gca, 'ydir', 'reverse', 'activepositionproperty', 'outerposition'); ylabel ({'semilogy (x, -y)', 'ydir = reversed'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "semilogy_03.png" ... '); tic (); print ('-dpng', 'semilogy_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "semilogy_03.png" already exists.\n'); end catch fprintf ('ERROR in semilogy_03: %s\n', lasterr ()); err_fid = fopen ('semilogy_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('semilogyerr_01.png', 'file')) rand ('seed', 1); tic (); clf; x = 0.25:0.25:10; y = wblpdf (x, 4, 2); eyu = rand (size (y)); eyl = 1.0 - 1./(1+eyu); semilogyerr (x, y, eyl.*y, eyu.*y, '~-d'); xlim ([0 10]); title ({'semilogyerr(): semilogy() plot with errorbars', ... 'Y-axis is logarithmic'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "semilogyerr_01.png" ... '); tic (); print ('-dpng', 'semilogyerr_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "semilogyerr_01.png" already exists.\n'); end catch fprintf ('ERROR in semilogyerr_01: %s\n', lasterr ()); err_fid = fopen ('semilogyerr_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('shrinkfaces_01.png', 'file')) rand ('seed', 1); tic (); clf; faces = [1 2 3; 1 3 4]; vertices = [0 0; 1 0; 1 1; 0 1]; patch ('Faces', faces, 'Vertices', vertices, 'FaceColor', 'none'); fv = shrinkfaces (faces, vertices, 0.25); patch (fv); axis equal; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "shrinkfaces_01.png" ... '); tic (); print ('-dpng', 'shrinkfaces_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "shrinkfaces_01.png" already exists.\n'); end catch fprintf ('ERROR in shrinkfaces_01: %s\n', lasterr ()); err_fid = fopen ('shrinkfaces_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('shrinkfaces_02.png', 'file')) rand ('seed', 1); tic (); clf; faces = [1 2 3 4; 5 6 7 8]; vertices = [0 0; 1 0; 2 1; 1 1; 2 0; 3 0; 4 1; 3.5 1]; patch ('Faces', faces, 'Vertices', vertices, 'FaceColor', 'none'); fv = shrinkfaces (faces, vertices, 0.25); patch (fv); axis equal; grid on; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "shrinkfaces_02.png" ... '); tic (); print ('-dpng', 'shrinkfaces_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "shrinkfaces_02.png" already exists.\n'); end catch fprintf ('ERROR in shrinkfaces_02: %s\n', lasterr ()); err_fid = fopen ('shrinkfaces_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('shrinkfaces_03.png', 'file')) rand ('seed', 1); tic (); clf; faces = [1 2 3 4]; vertices = [-1 2; 0 0; 1 2; 0 1]; patch ('Faces', faces, 'Vertices', vertices, 'FaceColor', 'none'); fv = shrinkfaces (faces, vertices, 0.25); patch (fv); axis equal; grid on; title 'faces which are not convex are clearly not allowed' t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "shrinkfaces_03.png" ... '); tic (); print ('-dpng', 'shrinkfaces_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "shrinkfaces_03.png" already exists.\n'); end catch fprintf ('ERROR in shrinkfaces_03: %s\n', lasterr ()); err_fid = fopen ('shrinkfaces_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('shrinkfaces_04.png', 'file')) rand ('seed', 1); tic (); clf; [phi r] = meshgrid (linspace (0, 1.5*pi, 16), linspace (1, 2, 4)); tri = delaunay (phi(:), r(:)); v = [r(:).*sin(phi(:)) r(:).*cos(phi(:))]; p = patch ('Faces', tri, 'Vertices', v, 'FaceColor', 'none'); fv = shrinkfaces (p); patch (fv); axis equal; grid on; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "shrinkfaces_04.png" ... '); tic (); print ('-dpng', 'shrinkfaces_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "shrinkfaces_04.png" already exists.\n'); end catch fprintf ('ERROR in shrinkfaces_04: %s\n', lasterr ()); err_fid = fopen ('shrinkfaces_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('shrinkfaces_05.png', 'file')) rand ('seed', 1); tic (); clf; N = 10; % N intervals per axis [x, y, z] = meshgrid (linspace (-4,4,N+1)); val = x.^3 + y.^3 + z.^3; fv = isosurface (x, y, z, val, 3, z); p = patch ('Faces', fv.faces, 'Vertices', fv.vertices, 'FaceVertexCData', ... fv.facevertexcdata, 'FaceColor', 'interp', 'EdgeColor', 'black'); axis equal; view (115, 30); drawnow; shrinkfaces (p, 0.6); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "shrinkfaces_05.png" ... '); tic (); print ('-dpng', 'shrinkfaces_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "shrinkfaces_05.png" already exists.\n'); end catch fprintf ('ERROR in shrinkfaces_05: %s\n', lasterr ()); err_fid = fopen ('shrinkfaces_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('slice_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [x, y, z] = meshgrid (linspace (-8, 8, 32)); v = sin (sqrt (x.^2 + y.^2 + z.^2)) ./ (sqrt (x.^2 + y.^2 + z.^2)); slice (x, y, z, v, [], 0, []); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "slice_01.png" ... '); tic (); print ('-dpng', 'slice_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "slice_01.png" already exists.\n'); end catch fprintf ('ERROR in slice_01: %s\n', lasterr ()); err_fid = fopen ('slice_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('slice_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [x, y, z] = meshgrid (linspace (-8, 8, 32)); v = sin (sqrt (x.^2 + y.^2 + z.^2)) ./ (sqrt (x.^2 + y.^2 + z.^2)); [xi, yi] = meshgrid (linspace (-7, 7)); zi = xi + yi; slice (x, y, z, v, xi, yi, zi); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "slice_02.png" ... '); tic (); print ('-dpng', 'slice_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "slice_02.png" already exists.\n'); end catch fprintf ('ERROR in slice_02: %s\n', lasterr ()); err_fid = fopen ('slice_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('sombrero_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); sombrero (41); title ('sombrero() function'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "sombrero_01.png" ... '); tic (); print ('-dpng', 'sombrero_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "sombrero_01.png" already exists.\n'); end catch fprintf ('ERROR in sombrero_01: %s\n', lasterr ()); err_fid = fopen ('sombrero_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stairs_01.png', 'file')) rand ('seed', 1); tic (); clf; rand_1x10_data1 = [0.073, 0.455, 0.837, 0.124, 0.426, 0.781, 0.004, 0.024, 0.519, 0.698]; y = rand_1x10_data1; stairs (y); title ('stairs() plot of y-data'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stairs_01.png" ... '); tic (); print ('-dpng', 'stairs_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stairs_01.png" already exists.\n'); end catch fprintf ('ERROR in stairs_01: %s\n', lasterr ()); err_fid = fopen ('stairs_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stairs_02.png', 'file')) rand ('seed', 1); tic (); clf; x = 1:10; rand_1x10_data2 = [0.014, 0.460, 0.622, 0.394, 0.531, 0.378, 0.466, 0.788, 0.342, 0.893]; y = rand_1x10_data2; [xs, ys] = stairs (x, y); plot (xs, ys); title ('plot() of stairs() generated data'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stairs_02.png" ... '); tic (); print ('-dpng', 'stairs_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stairs_02.png" already exists.\n'); end catch fprintf ('ERROR in stairs_02: %s\n', lasterr ()); err_fid = fopen ('stairs_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stairs_03.png', 'file')) rand ('seed', 1); tic (); clf; stairs (1:9, '-o'); title ('stairs() plot with linespec to modify marker'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stairs_03.png" ... '); tic (); print ('-dpng', 'stairs_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stairs_03.png" already exists.\n'); end catch fprintf ('ERROR in stairs_03: %s\n', lasterr ()); err_fid = fopen ('stairs_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stairs_04.png', 'file')) rand ('seed', 1); tic (); clf; stairs (9:-1:1, 'marker', 's', 'markersize', 10, 'markerfacecolor', 'm'); title ('stairs() plot with prop/val pairs to modify appearance'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stairs_04.png" ... '); tic (); print ('-dpng', 'stairs_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stairs_04.png" already exists.\n'); end catch fprintf ('ERROR in stairs_04: %s\n', lasterr ()); err_fid = fopen ('stairs_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stairs_05.png', 'file')) rand ('seed', 1); tic (); clf; N = 11; x = 0:(N-1); y = rand (1, N); hs = stairs (x(1), y(1)); axis ([1, N-1 0, 1]); title ('stairs plot data modified through handle'); for k = 2:N set (hs, 'xdata', x(1:k), 'ydata', y(1:k)); drawnow (); pause (0.2); end t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stairs_05.png" ... '); tic (); print ('-dpng', 'stairs_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stairs_05.png" already exists.\n'); end catch fprintf ('ERROR in stairs_05: %s\n', lasterr ()); err_fid = fopen ('stairs_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stem_01.png', 'file')) rand ('seed', 1); tic (); clf; y = 1:10; stem (y); title ('stem plot of y-values only'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stem_01.png" ... '); tic (); print ('-dpng', 'stem_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stem_01.png" already exists.\n'); end catch fprintf ('ERROR in stem_01: %s\n', lasterr ()); err_fid = fopen ('stem_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stem_02.png', 'file')) rand ('seed', 1); tic (); clf; x = 1:10; y = 2*x; stem (x, y); title ('stem plot of x and y-values'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stem_02.png" ... '); tic (); print ('-dpng', 'stem_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stem_02.png" already exists.\n'); end catch fprintf ('ERROR in stem_02: %s\n', lasterr ()); err_fid = fopen ('stem_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stem_03.png', 'file')) rand ('seed', 1); tic (); clf; x = 1:10; y = 2*x; h = stem (x, y, 'r'); title ('stem plot with modified color'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stem_03.png" ... '); tic (); print ('-dpng', 'stem_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stem_03.png" already exists.\n'); end catch fprintf ('ERROR in stem_03: %s\n', lasterr ()); err_fid = fopen ('stem_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stem_04.png', 'file')) rand ('seed', 1); tic (); clf; x = 1:10; y = 2*x; h = stem (x, y, '-.k'); title ('stem plot with modified line style and color'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stem_04.png" ... '); tic (); print ('-dpng', 'stem_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stem_04.png" already exists.\n'); end catch fprintf ('ERROR in stem_04: %s\n', lasterr ()); err_fid = fopen ('stem_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stem_05.png', 'file')) rand ('seed', 1); tic (); clf; x = 1:10; y = 2*x; h = stem (x, y, '-.ks'); title ('stem plot with modified line style, color, and marker'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stem_05.png" ... '); tic (); print ('-dpng', 'stem_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stem_05.png" already exists.\n'); end catch fprintf ('ERROR in stem_05: %s\n', lasterr ()); err_fid = fopen ('stem_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stem_06.png', 'file')) rand ('seed', 1); tic (); clf; x = 1:10; y = 2*x; h = stem (x, y, 'filled'); title ('stem plot with "filled" markers'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stem_06.png" ... '); tic (); print ('-dpng', 'stem_06.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stem_06.png" already exists.\n'); end catch fprintf ('ERROR in stem_06: %s\n', lasterr ()); err_fid = fopen ('stem_06.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stem_07.png', 'file')) rand ('seed', 1); tic (); clf; x = 1:10; y = 2*x; h = stem (x, y, 'markerfacecolor', [1 0 1]); title ('stem plot modified with property/value pair'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stem_07.png" ... '); tic (); print ('-dpng', 'stem_07.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stem_07.png" already exists.\n'); end catch fprintf ('ERROR in stem_07: %s\n', lasterr ()); err_fid = fopen ('stem_07.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stem_08.png', 'file')) rand ('seed', 1); tic (); clf; x = (0 : 10)'; y = [sin(x), cos(x)]; h = stem (x, y); set (h(2), 'color', 'g'); set (h(1), 'basevalue', -0.75); title ('stem plots modified through hggroup handle'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stem_08.png" ... '); tic (); print ('-dpng', 'stem_08.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stem_08.png" already exists.\n'); end catch fprintf ('ERROR in stem_08: %s\n', lasterr ()); err_fid = fopen ('stem_08.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stem_09.png', 'file')) rand ('seed', 1); tic (); clf; N = 11; x = 0:(N-1); y = rand (1, N); hs = stem (x(1), y(1)); set (gca (), 'xlim', [1, N-1], 'ylim', [0, 1]); title ('stem plot data modified through hggroup handle'); for k=2:N set (hs, 'xdata', x(1:k), 'ydata', y(1:k)) drawnow (); pause (0.2); end t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stem_09.png" ... '); tic (); print ('-dpng', 'stem_09.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stem_09.png" already exists.\n'); end catch fprintf ('ERROR in stem_09: %s\n', lasterr ()); err_fid = fopen ('stem_09.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stem3_01.png', 'file')) rand ('seed', 1); tic (); clf; theta = 0:0.2:6; stem3 (cos (theta), sin (theta), theta); title ('stem3() plot'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stem3_01.png" ... '); tic (); print ('-dpng', 'stem3_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stem3_01.png" already exists.\n'); end catch fprintf ('ERROR in stem3_01: %s\n', lasterr ()); err_fid = fopen ('stem3_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stemleaf_01.png', 'file')) rand ('seed', 1); tic (); %% Unsorted plot: x = [-22 12 -28 52 39 -2 12 10 11 11 42 38 44 18 44]; stemleaf (x, 'Unsorted plot'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stemleaf_01.png" ... '); tic (); print ('-dpng', 'stemleaf_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stemleaf_01.png" already exists.\n'); end catch fprintf ('ERROR in stemleaf_01: %s\n', lasterr ()); err_fid = fopen ('stemleaf_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stemleaf_02.png', 'file')) rand ('seed', 1); tic (); %% Sorted leaves: x = [-22 12 -28 52 39 -2 12 10 11 11 42 38 44 18 44]; y = sort (x); stemleaf (y, 'Sorted leaves'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stemleaf_02.png" ... '); tic (); print ('-dpng', 'stemleaf_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stemleaf_02.png" already exists.\n'); end catch fprintf ('ERROR in stemleaf_02: %s\n', lasterr ()); err_fid = fopen ('stemleaf_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stemleaf_03.png', 'file')) rand ('seed', 1); tic (); %% Sorted leaves (large dataset): x = [-22 12 -28 52 39 -2 12 10 11 11 42 38 44 18 44 37 113 124 37 48 ... 127 36 29 31 125 139 131 115 105 132 104 123 35 113 122 42 117 119 ... 58 109 23 105 63 27 44 105 99 41 128 121 116 125 32 61 37 127 29 113 ... 121 58 114 126 53 114 96 25 109 7 31 141 46 -13 71 43 117 116 27 7 ... 68 40 31 115 124 42 128 52 71 118 117 38 27 106 33 117 116 111 40 ... 119 47 105 57 122 109 124 115 43 120 43 27 27 18 28 48 125 107 114 ... 34 133 45 120 30 127 31 116 146 21 23 30 10 20 21 30 0 100 110 1 20 ... 0]; y = sort (x); stemleaf (y, 'Sorted leaves (large dataset)'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stemleaf_03.png" ... '); tic (); print ('-dpng', 'stemleaf_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stemleaf_03.png" already exists.\n'); end catch fprintf ('ERROR in stemleaf_03: %s\n', lasterr ()); err_fid = fopen ('stemleaf_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('stemleaf_04.png', 'file')) rand ('seed', 1); tic (); %% Gaussian leaves: x = fix (30 * randn (300,1)); stemleaf (x, 'Gaussian leaves'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "stemleaf_04.png" ... '); tic (); print ('-dpng', 'stemleaf_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "stemleaf_04.png" already exists.\n'); end catch fprintf ('ERROR in stemleaf_04: %s\n', lasterr ()); err_fid = fopen ('stemleaf_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('surf_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); Z = peaks (); surf (Z); title ({'surf() plot of peaks() function'; 'color determined by height Z'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "surf_01.png" ... '); tic (); print ('-dpng', 'surf_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "surf_01.png" already exists.\n'); end catch fprintf ('ERROR in surf_01: %s\n', lasterr ()); err_fid = fopen ('surf_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('surf_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); Z = sombrero (41); [Fx,Fy] = gradient (Z); surf (Z, Fx+Fy); shading interp; title ({'surf() plot of peaks() function'; ... 'facecolor is interpolated, color determined by gradient of Z'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "surf_02.png" ... '); tic (); print ('-dpng', 'surf_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "surf_02.png" already exists.\n'); end catch fprintf ('ERROR in surf_02: %s\n', lasterr ()); err_fid = fopen ('surf_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('surf_03.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [X,Y,Z] = sombrero (41); [~,Fy] = gradient (Z); surf (X, Y, Z, Fy); shading interp; title ({'surf() plot of peaks() function'; ... 'facecolor is interpolated, color determined by Y-gradient of Z'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "surf_03.png" ... '); tic (); print ('-dpng', 'surf_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "surf_03.png" already exists.\n'); end catch fprintf ('ERROR in surf_03: %s\n', lasterr ()); err_fid = fopen ('surf_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('surfc_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); Z = peaks (); surfc (Z); title ('surfc() combines surf/contour plots'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "surfc_01.png" ... '); tic (); print ('-dpng', 'surfc_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "surfc_01.png" already exists.\n'); end catch fprintf ('ERROR in surfc_01: %s\n', lasterr ()); err_fid = fopen ('surfc_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('surfc_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); Z = sombrero (41); [Fx,Fy] = gradient (Z); surfc (Z, Fx+Fy); shading interp; title ({'surfc() plot of sombrero() function'; ... 'facecolor is interpolated, color determined by gradient of Z'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "surfc_02.png" ... '); tic (); print ('-dpng', 'surfc_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "surfc_02.png" already exists.\n'); end catch fprintf ('ERROR in surfc_02: %s\n', lasterr ()); err_fid = fopen ('surfc_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('surfc_03.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [X,Y,Z] = sombrero (41); [~,Fy] = gradient (Z); surfc (X,Y,Z,Fy); shading interp; title ({'surfc() plot of peaks() function'; ... 'facecolor is interpolated, color determined by Y-gradient of Z'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "surfc_03.png" ... '); tic (); print ('-dpng', 'surfc_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "surfc_03.png" already exists.\n'); end catch fprintf ('ERROR in surfc_03: %s\n', lasterr ()); err_fid = fopen ('surfc_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('surfl_01.png', 'file')) rand ('seed', 1); tic (); clf; [X,Y,Z] = sombrero (41); colormap (copper (64)); surfl (X,Y,Z); shading interp; title ('surfl() with defaults'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "surfl_01.png" ... '); tic (); print ('-dpng', 'surfl_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "surfl_01.png" already exists.\n'); end catch fprintf ('ERROR in surfl_01: %s\n', lasterr ()); err_fid = fopen ('surfl_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('surfl_02.png', 'file')) rand ('seed', 1); tic (); clf; [X,Y,Z] = sombrero (41); colormap (copper (64)); surfl (X,Y,Z, [62.50,30], [0.2 0.6 0.4 25]); shading interp; title ('surfl() with lighting vector and material properties'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "surfl_02.png" ... '); tic (); print ('-dpng', 'surfl_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "surfl_02.png" already exists.\n'); end catch fprintf ('ERROR in surfl_02: %s\n', lasterr ()); err_fid = fopen ('surfl_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('surfnorm_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); surfnorm (peaks (32)); shading interp; title ({'surfnorm() shows surface and normals at each vertex', ... 'peaks() function with 32 faces'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "surfnorm_01.png" ... '); tic (); print ('-dpng', 'surfnorm_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "surfnorm_01.png" already exists.\n'); end catch fprintf ('ERROR in surfnorm_01: %s\n', lasterr ()); err_fid = fopen ('surfnorm_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('surfnorm_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); [x, y, z] = sombrero (10); surfnorm (x, y, z); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "surfnorm_02.png" ... '); tic (); print ('-dpng', 'surfnorm_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "surfnorm_02.png" already exists.\n'); end catch fprintf ('ERROR in surfnorm_02: %s\n', lasterr ()); err_fid = fopen ('surfnorm_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('tetramesh_01.png', 'file')) rand ('seed', 1); tic (); clf; d = [-1 1]; [x,y,z] = meshgrid (d, d, d); x = [x(:); 0]; y = [y(:); 0]; z = [z(:); 0]; tetra = delaunay (x, y, z); X = [x(:) y(:) z(:)]; colormap (jet (64)); h = tetramesh (tetra, X); set (h(1:2:end), 'Visible', 'off'); axis equal; view (30, 20); title ({'tetramesh() plot', ... 'colormap = jet (64), every other tetrahedron invisible'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "tetramesh_01.png" ... '); tic (); print ('-dpng', 'tetramesh_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "tetramesh_01.png" already exists.\n'); end catch fprintf ('ERROR in tetramesh_01: %s\n', lasterr ()); err_fid = fopen ('tetramesh_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('tetramesh_02.png', 'file')) rand ('seed', 1); tic (); clf; d = [-1 1]; [x,y,z] = meshgrid (d, d, d); x = [x(:); 0]; y = [y(:); 0]; z = [z(:); 0]; tetra = delaunay (x, y, z); X = [x(:) y(:) z(:)]; colormap (gray (256)); tetramesh (tetra, X, 21:20:241, 'EdgeColor', 'w'); axis equal; view (30, 20); title ({'tetramesh() plot', ... 'colormap = gray (256) with white edges'}); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "tetramesh_02.png" ... '); tic (); print ('-dpng', 'tetramesh_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "tetramesh_02.png" already exists.\n'); end catch fprintf ('ERROR in tetramesh_02: %s\n', lasterr ()); err_fid = fopen ('tetramesh_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('trimesh_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); old_state = rand ('state'); restore_state = onCleanup (@() rand ('state', old_state)); rand ('state', 10); N = 10; x = 3 - 6 * rand (N, N); y = 3 - 6 * rand (N, N); z = peaks (x, y); tri = delaunay (x(:), y(:)); trimesh (tri, x(:), y(:), z(:)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "trimesh_01.png" ... '); tic (); print ('-dpng', 'trimesh_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "trimesh_01.png" already exists.\n'); end catch fprintf ('ERROR in trimesh_01: %s\n', lasterr ()); err_fid = fopen ('trimesh_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('triplot_01.png', 'file')) rand ('seed', 1); tic (); clf; old_state = rand ('state'); restore_state = onCleanup (@() rand ('state', old_state)); rand ('state', 2); N = 20; x = rand (N, 1); y = rand (N, 1); tri = delaunay (x, y); triplot (tri, x, y); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "triplot_01.png" ... '); tic (); print ('-dpng', 'triplot_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "triplot_01.png" already exists.\n'); end catch fprintf ('ERROR in triplot_01: %s\n', lasterr ()); err_fid = fopen ('triplot_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('trisurf_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); N = 31; [x, y] = meshgrid (1:N); tri = delaunay (x(:), y(:)); z = peaks (N); h = trisurf (tri, x, y, z, 'facecolor', 'interp'); axis tight; zlim auto; title (sprintf ('facecolor = %s', get (h, 'facecolor'))); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "trisurf_01.png" ... '); tic (); print ('-dpng', 'trisurf_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "trisurf_01.png" already exists.\n'); end catch fprintf ('ERROR in trisurf_01: %s\n', lasterr ()); err_fid = fopen ('trisurf_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('trisurf_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); N = 31; [x, y] = meshgrid (1:N); tri = delaunay (x(:), y(:)); z = peaks (N); h = trisurf (tri, x, y, z, 'facecolor', 'flat'); axis tight; zlim auto; title (sprintf ('facecolor = %s', get (h, 'facecolor'))); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "trisurf_02.png" ... '); tic (); print ('-dpng', 'trisurf_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "trisurf_02.png" already exists.\n'); end catch fprintf ('ERROR in trisurf_02: %s\n', lasterr ()); err_fid = fopen ('trisurf_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('trisurf_03.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); old_state = rand ('state'); restore_state = onCleanup (@() rand ('state', old_state)); rand ('state', 10); N = 10; x = 3 - 6 * rand (N, N); y = 3 - 6 * rand (N, N); z = peaks (x, y); tri = delaunay (x(:), y(:)); trisurf (tri, x(:), y(:), z(:)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "trisurf_03.png" ... '); tic (); print ('-dpng', 'trisurf_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "trisurf_03.png" already exists.\n'); end catch fprintf ('ERROR in trisurf_03: %s\n', lasterr ()); err_fid = fopen ('trisurf_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('trisurf_04.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); x = rand (100, 1); y = rand (100, 1); z = x.^2 + y.^2; tri = delaunay (x, y); trisurf (tri, x, y, z); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "trisurf_04.png" ... '); tic (); print ('-dpng', 'trisurf_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "trisurf_04.png" already exists.\n'); end catch fprintf ('ERROR in trisurf_04: %s\n', lasterr ()); err_fid = fopen ('trisurf_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('trisurf_05.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); x = rand (100, 1); y = rand (100, 1); z = x.^2 + y.^2; tri = delaunay (x, y); trisurf (tri, x, y, z, 'facecolor', 'interp'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "trisurf_05.png" ... '); tic (); print ('-dpng', 'trisurf_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "trisurf_05.png" already exists.\n'); end catch fprintf ('ERROR in trisurf_05: %s\n', lasterr ()); err_fid = fopen ('trisurf_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('trisurf_06.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); x = rand (100, 1); y = rand (100, 1); z = x.^2 + y.^2; tri = delaunay (x, y); trisurf (tri, x, y, z, 'facecolor', 'interp', 'edgecolor', 'k'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "trisurf_06.png" ... '); tic (); print ('-dpng', 'trisurf_06.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "trisurf_06.png" already exists.\n'); end catch fprintf ('ERROR in trisurf_06: %s\n', lasterr ()); err_fid = fopen ('trisurf_06.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('waterfall_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); Z = peaks (); waterfall (Z); title ('waterfall() plot of peaks() function'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "waterfall_01.png" ... '); tic (); print ('-dpng', 'waterfall_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "waterfall_01.png" already exists.\n'); end catch fprintf ('ERROR in waterfall_01: %s\n', lasterr ()); err_fid = fopen ('waterfall_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('waterfall_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); Z = peaks (); subplot (1,2,1) meshz (Z); daspect ([2.5, 2.5, 1]); title ('meshz() plot'); subplot (1,2,2) waterfall (Z); daspect ([2.5, 2.5, 1]); title ('waterfall() plot'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "waterfall_02.png" ... '); tic (); print ('-dpng', 'waterfall_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "waterfall_02.png" already exists.\n'); end catch fprintf ('ERROR in waterfall_02: %s\n', lasterr ()); err_fid = fopen ('waterfall_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end close all try if (! exist ('copyobj_01.png', 'file')) rand ('seed', 1); tic (); hobj = figure ('name', 'Original', 'numbertitle', 'off'); hold on; x = 1:10; y = x.^2; dy = 2 * (.2 * x); y2 = (x - 3).^2; hg = errorbar (x, y, dy); set (hg, 'marker', '^', 'markerfacecolor', rand (1,3)); plot (x, y2, 'ok-'); legend ('errorbar', 'line'); drawnow (); pos = get (hobj, 'position'); scrn = get (0, 'screensize'); set (hobj, 'position', [scrn(3)/2-pos(3)-10, scrn(4)/2-pos(4)/2, pos(3:4)]); drawnow (); hnew = copyobj (hobj); drawnow (); set (hnew, 'name', 'Copyobj'); drawnow (); set (hnew, 'position', [scrn(3)/2, scrn(4)/2-pos(4)/2, pos(3:4)]); drawnow (); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "copyobj_01.png" ... '); tic (); print ('-dpng', 'copyobj_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "copyobj_01.png" already exists.\n'); end catch fprintf ('ERROR in copyobj_01: %s\n', lasterr ()); err_fid = fopen ('copyobj_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('copyobj_02.png', 'file')) rand ('seed', 1); tic (); hobj = figure ('name', 'Original', 'numbertitle', 'off'); subplot (2,2,1); hold on; contourf (rand (10, 10)); colorbar (); subplot (2,2,2); quiver (rand (10, 10), rand (10, 10)); subplot (2,2,3); colormap (jet (64)); hold on; sombrero (41); colorbar ('peer', gca, 'NorthOutside'); subplot (2,2,4); imagesc (rand (30, 30)); text (15, 15, 'Rotated text', ... 'HorizontAlalignment', 'Center', 'Rotation', 30); drawnow (); pos = get (hobj, 'position'); scrn = get (0, 'screensize'); set (hobj, 'position', [scrn(3)/2-pos(3)-10, scrn(4)/2-pos(4)/2, pos(3:4)]); drawnow (); hnew = copyobj (hobj); drawnow (); set (hnew, 'name', 'Copyobj'); drawnow (); set (hnew, 'position', [scrn(3)/2, scrn(4)/2-pos(4)/2, pos(3:4)]); drawnow (); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "copyobj_02.png" ... '); tic (); print ('-dpng', 'copyobj_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "copyobj_02.png" already exists.\n'); end catch fprintf ('ERROR in copyobj_02: %s\n', lasterr ()); err_fid = fopen ('copyobj_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('hold_01.png', 'file')) rand ('seed', 1); tic (); clf; t = linspace (0, 2*pi, 100); plot (t, sin (t)); hold on; plot (t, cos (t)); title ({'hold on', '2 plots shown on same graph'}); hold off; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "hold_01.png" ... '); tic (); print ('-dpng', 'hold_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "hold_01.png" already exists.\n'); end catch fprintf ('ERROR in hold_01: %s\n', lasterr ()); err_fid = fopen ('hold_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('hold_02.png', 'file')) rand ('seed', 1); tic (); clf; t = linspace (0, 2*pi, 100); plot (t, sin (t)); hold all; plot (t, cos (t)); title ({'hold all', '2 plots shown on same graph with linestyle also preserved'}); hold off; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "hold_02.png" ... '); tic (); print ('-dpng', 'hold_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "hold_02.png" already exists.\n'); end catch fprintf ('ERROR in hold_02: %s\n', lasterr ()); err_fid = fopen ('hold_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('hold_03.png', 'file')) rand ('seed', 1); tic (); clf; A = rand (100); [X, Y] = find (A > 0.95); imshow (A); hold on; plot (X, Y, 'o'); hold off; title ('hold with image and plot'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "hold_03.png" ... '); tic (); print ('-dpng', 'hold_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "hold_03.png" already exists.\n'); end catch fprintf ('ERROR in hold_03: %s\n', lasterr ()); err_fid = fopen ('hold_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('hold_04.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); hold on; imagesc (1 ./ hilb (4)); plot (1:4, '-s'); hold off; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "hold_04.png" ... '); tic (); print ('-dpng', 'hold_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "hold_04.png" already exists.\n'); end catch fprintf ('ERROR in hold_04: %s\n', lasterr ()); err_fid = fopen ('hold_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('hold_05.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); hold on; imagesc (1 ./ hilb (2)); imagesc (1 ./ hilb (4)); hold off; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "hold_05.png" ... '); tic (); print ('-dpng', 'hold_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "hold_05.png" already exists.\n'); end catch fprintf ('ERROR in hold_05: %s\n', lasterr ()); err_fid = fopen ('hold_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('hold_06.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); hold on; plot (1:4, '-s'); imagesc (1 ./ hilb (4)); hold off; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "hold_06.png" ... '); tic (); print ('-dpng', 'hold_06.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "hold_06.png" already exists.\n'); end catch fprintf ('ERROR in hold_06: %s\n', lasterr ()); err_fid = fopen ('hold_06.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('hold_07.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); t = linspace (-3, 3, 50); [x, y] = meshgrid (t, t); z = peaks (x, y); contourf (x, y, z, 10); hold on; plot (x(:), y(:), '^'); patch ([-1.0 1.0 1.0 -1.0 -1.0], [-1.0 -1.0 1.0 1.0 -1.0], 'red'); xlim ([-2.0 2.0]); ylim ([-2.0 2.0]); colorbar ('SouthOutside'); title ('Test script for some plot functions'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "hold_07.png" ... '); tic (); print ('-dpng', 'hold_07.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "hold_07.png" already exists.\n'); end catch fprintf ('ERROR in hold_07: %s\n', lasterr ()); err_fid = fopen ('hold_07.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('printd_01.png', 'file')) rand ('seed', 1); tic (); r2 = char ( ... 'stem step: 10, data: unsorted.', ... 'Hinges: lo: 12, hi: 42' , ... ' 1 | 22118' , ... ' 2 | 28' , ... ' 3 | 98' , ... ' 4 | 244' , ... ' 5 | 2' ); printd (r2, 'test_p.txt'); system ('cat test_p.txt'); delete ('test_p.txt'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "printd_01.png" ... '); tic (); print ('-dpng', 'printd_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "printd_01.png" already exists.\n'); end catch fprintf ('ERROR in printd_01: %s\n', lasterr ()); err_fid = fopen ('printd_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('refreshdata_01.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:0.1:10; y = sin (x); plot (x, y, 'ydatasource', 'y'); title ('refreshdata() showing moving sine curve'); axis manual; for i = 1 : 100 pause (0); y = sin (x + 0.1 * i); refreshdata (gcf, 'caller'); end t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "refreshdata_01.png" ... '); tic (); print ('-dpng', 'refreshdata_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "refreshdata_01.png" already exists.\n'); end catch fprintf ('ERROR in refreshdata_01: %s\n', lasterr ()); err_fid = fopen ('refreshdata_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('subplot_01.png', 'file')) rand ('seed', 1); tic (); clf; r = 3; c = 3; fmt = {'horizontalalignment', 'center', 'verticalalignment', 'middle'}; for n = 1 : r*c subplot (r, c, n); xlabel (sprintf ('xlabel %%d', n)); ylabel (sprintf ('ylabel %%d', n)); title (sprintf ('title %%d', n)); text (0.5, 0.5, sprintf ('subplot(%d,%d,%d)', r, c, n), fmt{:}); axis ([0 1 0 1]); end subplot (r, c, 1:3); xlabel (sprintf ('xlabel %%d:%d', 1, 3)); ylabel (sprintf ('ylabel %%d:%d', 1, 3)); title (sprintf ('title %%d:%d', 1, 3)); text (0.5, 0.5, sprintf ('subplot(%d,%d,%d:%d)', r, c, 1, 3), fmt{:}); axis ([0 1 0 1]); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "subplot_01.png" ... '); tic (); print ('-dpng', 'subplot_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "subplot_01.png" already exists.\n'); end catch fprintf ('ERROR in subplot_01: %s\n', lasterr ()); err_fid = fopen ('subplot_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('subplot_02.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:1; for n = 1:4 subplot (2,2,n, 'align'); plot (x, x); xlabel (sprintf ('xlabel (2,2,%d)', n)); ylabel (sprintf ('ylabel (2,2,%d)', n)); title (sprintf ('title (2,2,%d)', n)); end subplot (1,2,1, 'align'); plot (x, x); xlabel ('xlabel (1,2,1)'); ylabel ('ylabel (1,2,1)'); title ('title (1,2,1)'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "subplot_02.png" ... '); tic (); print ('-dpng', 'subplot_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "subplot_02.png" already exists.\n'); end catch fprintf ('ERROR in subplot_02: %s\n', lasterr ()); err_fid = fopen ('subplot_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('subplot_03.png', 'file')) rand ('seed', 1); tic (); clf; x = 0:10; ax(1) = subplot (221); set (ax(1), 'tag', '1'); plot (x, rand (3, 11)) title ('x & y labels & ticklabels'); xlabel xlabel ylabel ylabel ax(2) = subplot (222); set (ax(2), 'tag', '2'); plot (x, rand (3, 11)) title ('no labels'); axis ('nolabel','tic') ax(3) = subplot (223); set (ax(3), 'tag', '3'); plot (x, rand (3, 11)) title ('no labels'); axis ('nolabel','tic') ax(4) = subplot (224); set (ax(4), 'tag', '4'); plot (x, rand (3, 11)) title ('x & y labels & ticklabels'); xlabel xlabel ylabel ylabel t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "subplot_03.png" ... '); tic (); print ('-dpng', 'subplot_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "subplot_03.png" already exists.\n'); end catch fprintf ('ERROR in subplot_03: %s\n', lasterr ()); err_fid = fopen ('subplot_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('subplot_04.png', 'file')) rand ('seed', 1); tic (); x = 0:10; subplot (221); plot (x, rand (3, 11)) ylim ([0, 1]); text (0.5, 0.5, '{x,y}labels & {x,y}ticklabels', ... 'horizontalalignment', 'center', ... 'units', 'normalized'); xlabel xlabel ylabel ylabel title title subplot (222); plot (x, rand (3, 11)) axis ('labely'); ylabel ylabel text (0.5, 0.5, 'no xlabels, xticklabels', ... 'horizontalalignment', 'center', ... 'units', 'normalized'); subplot (223); plot (x, rand (3, 11)) axis ('labelx'); text (0.5, 0.5, 'no ylabels, yticklabels', ... 'horizontalalignment', 'center', ... 'units', 'normalized'); xlabel xlabel title title subplot (224); plot (x, rand (3, 11)) axis ('nolabel','tic'); text (0.5, 0.5, 'no {x,y}labels, {x,y}ticklabels', ... 'horizontalalignment', 'center', ... 'units', 'normalized'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "subplot_04.png" ... '); tic (); print ('-dpng', 'subplot_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "subplot_04.png" already exists.\n'); end catch fprintf ('ERROR in subplot_04: %s\n', lasterr ()); err_fid = fopen ('subplot_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('zoom_01.png', 'file')) rand ('seed', 1); tic (); clf; sombrero (41); pause (1); %% zoom in by a factor of 2 zoom (2); pause (1); %% return to original zoom level zoom out; pause (1); %% zoom in by a factor of 2 zoom (2); pause (1); %% set this zoom level as the "initial zoom level" %% and zoom in some more zoom reset; zoom (2); pause (1); %% return to zoom level set by last call to 'zoom reset' zoom out; t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "zoom_01.png" ... '); tic (); print ('-dpng', 'zoom_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "zoom_01.png" already exists.\n'); end catch fprintf ('ERROR in zoom_01: %s\n', lasterr ()); err_fid = fopen ('zoom_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end close all try if (! exist ('autumn_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'autumn' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (autumn (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "autumn_01.png" ... '); tic (); print ('-dpng', 'autumn_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "autumn_01.png" already exists.\n'); end catch fprintf ('ERROR in autumn_01: %s\n', lasterr ()); err_fid = fopen ('autumn_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('bone_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'bone' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (bone (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "bone_01.png" ... '); tic (); print ('-dpng', 'bone_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "bone_01.png" already exists.\n'); end catch fprintf ('ERROR in bone_01: %s\n', lasterr ()); err_fid = fopen ('bone_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('brighten_01.png', 'file')) rand ('seed', 1); tic (); %% First figure uses default grayscale colormap figure; colormap (gray (64)); image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", "xy"); title ("default grayscale colormap"); pos = get (gcf, "position"); pos(1) += pos(3) + 25; %% Second figure uses brightened grayscale colormap figure ('position', pos); colormap (gray (64)); image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", "xy"); brighten (0.5); title ('grayscale colormap brightened by 0.5'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "brighten_01.png" ... '); tic (); print ('-dpng', 'brighten_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "brighten_01.png" already exists.\n'); end catch fprintf ('ERROR in brighten_01: %s\n', lasterr ()); err_fid = fopen ('brighten_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('cmpermute_01.png', 'file')) rand ('seed', 1); tic (); [Y, newmap] = cmpermute ([1:4], hot (4), 4:-1:1) %% colormap will be arranged in reverse order (so will image) t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "cmpermute_01.png" ... '); tic (); print ('-dpng', 'cmpermute_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "cmpermute_01.png" already exists.\n'); end catch fprintf ('ERROR in cmpermute_01: %s\n', lasterr ()); err_fid = fopen ('cmpermute_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('cmunique_01.png', 'file')) rand ('seed', 1); tic (); [Y, newmap] = cmunique ([1:4;5:8], [hot(4);hot(4)]) %% Both rows are equal since map maps colors to the same value %% cmunique will give the same indices to both t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "cmunique_01.png" ... '); tic (); print ('-dpng', 'cmunique_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "cmunique_01.png" already exists.\n'); end catch fprintf ('ERROR in cmunique_01: %s\n', lasterr ()); err_fid = fopen ('cmunique_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('colorcube_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'colorcube' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (colorcube (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "colorcube_01.png" ... '); tic (); print ('-dpng', 'colorcube_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "colorcube_01.png" already exists.\n'); end catch fprintf ('ERROR in colorcube_01: %s\n', lasterr ()); err_fid = fopen ('colorcube_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('contrast_01.png', 'file')) rand ('seed', 1); tic (); figure; img = reshape (1:100, 10, 10); imagesc (img); colormap (gray (64)); title ("Image with default 64 gray levels"); pos = get (gcf, "position"); pos(1) += pos(3) + 25; figure ("position", pos); colormap (contrast (img, 10)); imagesc (img); title ('Image with contrast enhanced'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "contrast_01.png" ... '); tic (); print ('-dpng', 'contrast_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "contrast_01.png" already exists.\n'); end catch fprintf ('ERROR in contrast_01: %s\n', lasterr ()); err_fid = fopen ('contrast_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('cool_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'cool' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (cool (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "cool_01.png" ... '); tic (); print ('-dpng', 'cool_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "cool_01.png" already exists.\n'); end catch fprintf ('ERROR in cool_01: %s\n', lasterr ()); err_fid = fopen ('cool_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('copper_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'copper' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (copper (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "copper_01.png" ... '); tic (); print ('-dpng', 'copper_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "copper_01.png" already exists.\n'); end catch fprintf ('ERROR in copper_01: %s\n', lasterr ()); err_fid = fopen ('copper_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('cubehelix_01.png', 'file')) rand ('seed', 1); tic (); subplot (1, 2, 1) rgbplot (cubehelix (256), 'composite') subplot (1, 2, 2) rgbplot (cubehelix (256)) t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "cubehelix_01.png" ... '); tic (); print ('-dpng', 'cubehelix_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "cubehelix_01.png" already exists.\n'); end catch fprintf ('ERROR in cubehelix_01: %s\n', lasterr ()); err_fid = fopen ('cubehelix_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('flag_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'flag' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (flag (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "flag_01.png" ... '); tic (); print ('-dpng', 'flag_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "flag_01.png" already exists.\n'); end catch fprintf ('ERROR in flag_01: %s\n', lasterr ()); err_fid = fopen ('flag_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('gray_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'gray' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (gray (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "gray_01.png" ... '); tic (); print ('-dpng', 'gray_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "gray_01.png" already exists.\n'); end catch fprintf ('ERROR in gray_01: %s\n', lasterr ()); err_fid = fopen ('gray_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('hot_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'hot' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (hot (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "hot_01.png" ... '); tic (); print ('-dpng', 'hot_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "hot_01.png" already exists.\n'); end catch fprintf ('ERROR in hot_01: %s\n', lasterr ()); err_fid = fopen ('hot_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('hsv_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'hsv' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (hsv (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "hsv_01.png" ... '); tic (); print ('-dpng', 'hsv_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "hsv_01.png" already exists.\n'); end catch fprintf ('ERROR in hsv_01: %s\n', lasterr ()); err_fid = fopen ('hsv_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('image_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap (jet (21)); img = 1 ./ hilb (11); x = y = -5:5; subplot (2,2,1); h = image (x, y, img); ylabel ("limits = [-5.5, 5.5]"); title ("image (x, y, img)"); subplot (2,2,2); h = image (-x, y, img); title ("image (-x, y, img)"); subplot (2,2,3); h = image (x, -y, img); title ("image (x, -y, img)"); ylabel ("limits = [-5.5, 5.5]"); subplot (2,2,4); h = image (-x, -y, img); title ('image (-x, -y, img)'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "image_01.png" ... '); tic (); print ('-dpng', 'image_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "image_01.png" already exists.\n'); end catch fprintf ('ERROR in image_01: %s\n', lasterr ()); err_fid = fopen ('image_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('imagesc_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap ("default"); img = 1 ./ hilb (11); x = y = -5:5; subplot (2,2,1); h = imagesc (x, y, img); ylabel ("limits = [-5.5, 5.5]"); title ("imagesc (x, y, img)"); subplot (2,2,2); h = imagesc (-x, y, img); title ("imagesc (-x, y, img)"); subplot (2,2,3); h = imagesc (x, -y, img); title ("imagesc (x, -y, img)"); ylabel ("limits = [-5.5, 5.5]"); subplot (2,2,4); h = imagesc (-x, -y, img); title ('imagesc (-x, -y, img)'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "imagesc_01.png" ... '); tic (); print ('-dpng', 'imagesc_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "imagesc_01.png" already exists.\n'); end catch fprintf ('ERROR in imagesc_01: %s\n', lasterr ()); err_fid = fopen ('imagesc_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('imagesc_02.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); g = 0.1:0.1:10; h = g'*g; imagesc (g, g, sin (h)); hold on; imagesc (g, g+12, cos (h/2)); axis ([0 10 0 22]); hold off; title ('two consecutive images'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "imagesc_02.png" ... '); tic (); print ('-dpng', 'imagesc_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "imagesc_02.png" already exists.\n'); end catch fprintf ('ERROR in imagesc_02: %s\n', lasterr ()); err_fid = fopen ('imagesc_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('imagesc_03.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); g = 0.1:0.1:10; h = g'*g; imagesc (g, g, sin (h)); hold all; plot (g, 11.0 * ones (size (g))); imagesc (g, g+12, cos (h/2)); axis ([0 10 0 22]); hold off; title ('image, line, image'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "imagesc_03.png" ... '); tic (); print ('-dpng', 'imagesc_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "imagesc_03.png" already exists.\n'); end catch fprintf ('ERROR in imagesc_03: %s\n', lasterr ()); err_fid = fopen ('imagesc_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('imagesc_04.png', 'file')) rand ('seed', 1); tic (); clf; colormap ('default'); g = 0.1:0.1:10; h = g'*g; plot (g, 10.5 * ones (size (g))); hold all; imagesc (g, g, sin (h)); plot (g, 11.0 * ones (size (g))); imagesc (g, g+12, cos (h/2)); plot (g, 11.5 * ones (size (g))); axis ([0 10 0 22]); hold off; title ('line, image, line, image, line'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "imagesc_04.png" ... '); tic (); print ('-dpng', 'imagesc_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "imagesc_04.png" already exists.\n'); end catch fprintf ('ERROR in imagesc_04: %s\n', lasterr ()); err_fid = fopen ('imagesc_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('imshow_01.png', 'file')) rand ('seed', 1); tic (); clf; imshow ('default.img'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "imshow_01.png" ... '); tic (); print ('-dpng', 'imshow_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "imshow_01.png" already exists.\n'); end catch fprintf ('ERROR in imshow_01: %s\n', lasterr ()); err_fid = fopen ('imshow_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('imshow_02.png', 'file')) rand ('seed', 1); tic (); clf; imshow ('default.img'); colormap (autumn (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "imshow_02.png" ... '); tic (); print ('-dpng', 'imshow_02.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "imshow_02.png" already exists.\n'); end catch fprintf ('ERROR in imshow_02: %s\n', lasterr ()); err_fid = fopen ('imshow_02.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('imshow_03.png', 'file')) rand ('seed', 1); tic (); clf; [I, M] = imread ('default.img'); imshow (I, M); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "imshow_03.png" ... '); tic (); print ('-dpng', 'imshow_03.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "imshow_03.png" already exists.\n'); end catch fprintf ('ERROR in imshow_03: %s\n', lasterr ()); err_fid = fopen ('imshow_03.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('imshow_04.png', 'file')) rand ('seed', 1); tic (); clf; [I, M] = imread ('default.img'); [R, G, B] = ind2rgb (I, M); imshow (cat (3, R, G*0.5, B*0.8)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "imshow_04.png" ... '); tic (); print ('-dpng', 'imshow_04.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "imshow_04.png" already exists.\n'); end catch fprintf ('ERROR in imshow_04: %s\n', lasterr ()); err_fid = fopen ('imshow_04.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('imshow_05.png', 'file')) rand ('seed', 1); tic (); clf; imshow (rand (100, 100)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "imshow_05.png" ... '); tic (); print ('-dpng', 'imshow_05.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "imshow_05.png" already exists.\n'); end catch fprintf ('ERROR in imshow_05: %s\n', lasterr ()); err_fid = fopen ('imshow_05.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('imshow_06.png', 'file')) rand ('seed', 1); tic (); clf; imshow (rand (100, 100, 3)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "imshow_06.png" ... '); tic (); print ('-dpng', 'imshow_06.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "imshow_06.png" already exists.\n'); end catch fprintf ('ERROR in imshow_06: %s\n', lasterr ()); err_fid = fopen ('imshow_06.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('imshow_07.png', 'file')) rand ('seed', 1); tic (); clf; imshow (100*rand (100, 100, 3)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "imshow_07.png" ... '); tic (); print ('-dpng', 'imshow_07.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "imshow_07.png" already exists.\n'); end catch fprintf ('ERROR in imshow_07: %s\n', lasterr ()); err_fid = fopen ('imshow_07.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('imshow_08.png', 'file')) rand ('seed', 1); tic (); clf; imshow (rand (100, 100)); colormap (jet (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "imshow_08.png" ... '); tic (); print ('-dpng', 'imshow_08.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "imshow_08.png" already exists.\n'); end catch fprintf ('ERROR in imshow_08: %s\n', lasterr ()); err_fid = fopen ('imshow_08.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('jet_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'jet' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (jet (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "jet_01.png" ... '); tic (); print ('-dpng', 'jet_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "jet_01.png" already exists.\n'); end catch fprintf ('ERROR in jet_01: %s\n', lasterr ()); err_fid = fopen ('jet_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('lines_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'lines' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (lines (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "lines_01.png" ... '); tic (); print ('-dpng', 'lines_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "lines_01.png" already exists.\n'); end catch fprintf ('ERROR in lines_01: %s\n', lasterr ()); err_fid = fopen ('lines_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('ocean_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'ocean' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (ocean (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "ocean_01.png" ... '); tic (); print ('-dpng', 'ocean_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "ocean_01.png" already exists.\n'); end catch fprintf ('ERROR in ocean_01: %s\n', lasterr ()); err_fid = fopen ('ocean_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('pink_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'pink' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (pink (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "pink_01.png" ... '); tic (); print ('-dpng', 'pink_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "pink_01.png" already exists.\n'); end catch fprintf ('ERROR in pink_01: %s\n', lasterr ()); err_fid = fopen ('pink_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('prism_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'prism' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (prism (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "prism_01.png" ... '); tic (); print ('-dpng', 'prism_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "prism_01.png" already exists.\n'); end catch fprintf ('ERROR in prism_01: %s\n', lasterr ()); err_fid = fopen ('prism_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('rainbow_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'rainbow' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (rainbow (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "rainbow_01.png" ... '); tic (); print ('-dpng', 'rainbow_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "rainbow_01.png" already exists.\n'); end catch fprintf ('ERROR in rainbow_01: %s\n', lasterr ()); err_fid = fopen ('rainbow_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('rgbplot_01.png', 'file')) rand ('seed', 1); tic (); clf; subplot (1, 2, 1); rgbplot (ocean, "profile"); subplot (1, 2, 2); rgbplot (ocean, 'composite'); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "rgbplot_01.png" ... '); tic (); print ('-dpng', 'rgbplot_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "rgbplot_01.png" already exists.\n'); end catch fprintf ('ERROR in rgbplot_01: %s\n', lasterr ()); err_fid = fopen ('rgbplot_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('spinmap_01.png', 'file')) rand ('seed', 1); tic (); clf; colormap (rainbow (128)); imagesc (1:8); axis off; title ('Rotate color bars to the right'); spinmap (3, 1); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "spinmap_01.png" ... '); tic (); print ('-dpng', 'spinmap_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "spinmap_01.png" already exists.\n'); end catch fprintf ('ERROR in spinmap_01: %s\n', lasterr ()); err_fid = fopen ('spinmap_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('spring_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'spring' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (spring (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "spring_01.png" ... '); tic (); print ('-dpng', 'spring_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "spring_01.png" already exists.\n'); end catch fprintf ('ERROR in spring_01: %s\n', lasterr ()); err_fid = fopen ('spring_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('summer_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'summer' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (summer (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "summer_01.png" ... '); tic (); print ('-dpng', 'summer_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "summer_01.png" already exists.\n'); end catch fprintf ('ERROR in summer_01: %s\n', lasterr ()); err_fid = fopen ('summer_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('white_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'white' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (white (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "white_01.png" ... '); tic (); print ('-dpng', 'white_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "white_01.png" already exists.\n'); end catch fprintf ('ERROR in white_01: %s\n', lasterr ()); err_fid = fopen ('white_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end try if (! exist ('winter_01.png', 'file')) rand ('seed', 1); tic (); %% Show the 'winter' colormap as an image image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64)); axis ([1, 64, 0, 1], "ticy", 'xy'); colormap (winter (64)); t_plot = toc (); fig = (get (0, 'currentfigure')); if (~ isempty (fig)) figure (fig); fprintf ('Printing "winter_01.png" ... '); tic (); print ('-dpng', 'winter_01.png'); t_print = toc (); fprintf ('[%f %f] done\n',t_plot, t_print); end close ('all'); else fprintf ('File "winter_01.png" already exists.\n'); end catch fprintf ('ERROR in winter_01: %s\n', lasterr ()); err_fid = fopen ('winter_01.err', 'w'); fprintf (err_fid, '%s', lasterr ()); fclose (err_fid); end close all diary off end