Mercurial > hg > octave-lyh
comparison scripts/plot/__gnuplot_open_stream__.m @ 9113:4bb94a71913b
__gnuplot_open_stream__.m: New function and its application.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Sun, 12 Apr 2009 20:40:53 -0400 |
parents | |
children | ff8d7f3ad203 fe30458b1de8 |
comparison
equal
deleted
inserted
replaced
9112:f5b51f54f44e | 9113:4bb94a71913b |
---|---|
1 ## Copyright (C) 2009 Ben Abbott | |
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 2 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 Octave; see the file COPYING. If not, see | |
15 ## <http://www.gnu.org/licenses/>. | |
16 | |
17 ## -*- texinfo -*- | |
18 ## @deftypefn {Function File} {@var{stream}} __gnuplot_open_stream__ (@var{npipes}, @var{h}) | |
19 ## Undocumented internal function. | |
20 ## @end deftypefn | |
21 | |
22 ## Author: Ben Abbott <bpabbott@mac.com> | |
23 ## Created: 2009-04-11 | |
24 | |
25 function plot_stream = __gnuplot_open_stream__ (npipes, h) | |
26 cmd = gnuplot_binary (); | |
27 if (npipes > 1) | |
28 [plot_stream(1), plot_stream(2), pid] = popen2 (cmd); | |
29 if (pid < 0) | |
30 error ("__gnuplot_open_stream__: failed to open connection to gnuplot."); | |
31 endif | |
32 else | |
33 plot_stream = popen (cmd, "w"); | |
34 if (plot_stream < 0) | |
35 error ("__gnuplot_open_stream__: failed to open connection to gnuplot."); | |
36 endif | |
37 endif | |
38 if (nargin > 1) | |
39 set (h, "__plot_stream__", plot_stream); | |
40 endif | |
41 endfunction |