]> Creatis software - CreaPhase.git/blob - octave_packages/optim-1.2.0/private/__plot_cmds__.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / optim-1.2.0 / private / __plot_cmds__.m
1 %% Copyright (C) 2010, 2011 Olaf Till <olaf.till@uni-jena.de>
2 %%
3 %% This program is free software; you can redistribute it and/or modify
4 %% it under the terms of the GNU General Public License as published by
5 %% the Free Software Foundation; either version 3 of the License, or
6 %% (at your option) any later version.
7 %%
8 %% This program is distributed in the hope that it will be useful,
9 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
10 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 %% GNU General Public License for more details.
12 %%
13 %% You should have received a copy of the GNU General Public License
14 %% along with this program; If not, see <http://www.gnu.org/licenses/>.
15
16 function __plot_cmds__ (x, y, f)
17
18   persistent lgnd;
19   persistent use_x;
20   if (nargin == 0)
21     %% reset function
22     lgnd = [];
23     return;
24   end
25
26   if (length (size (f)) > 2)
27     return;
28   end
29
30   if (isempty (lgnd));
31     n = size (y, 2);
32     if (n == 1)
33       lgnd = {'data', 'fit'};
34     else
35       id = num2str ((1:n).');
36       lgnd1 = cat (2, repmat ('data ', n, 1), id);
37       lgnd2 = cat (2, repmat ('fit ', n, 1), id);
38       lgnd = cat (1, cellstr (lgnd1), cellstr (lgnd2));
39     end
40     use_x = size (x, 1) == size (y, 1);
41   end
42
43   x = x(:, 1);
44   if (use_x)
45     plot (x, y, 'marker', '+', 'linestyle', 'none', x, f);
46   else
47     plot (y, 'marker', '+', 'linestyle', 'none', f);
48   end
49   legend (lgnd);
50   drawnow;