[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
using stem (pK)
From: |
Wolfgang Lindner |
Subject: |
using stem (pK) |
Date: |
Mon, 5 Jun 2006 11:55:03 +0200 |
Dear octaver's,
I have some problems using the function stem.m from Paul Kienzle.
Here is what I do.
FIRST here is my script file p_.m:
diary .history
stemx
SECOND here is my script file stemx.m for testing stem (coming from pK):
t=0:0.1:2*pi; x=sin(t); idx=1:4:length(t);
plot(t,x,"r-+;sin(x);"); hold on
stem(t(idx), x(idx),"bo;struts;"); hold off
The source of stem.m is attached below.
THIRD invoking octave ..
GNU Octave, version 2.1.50 (i686-pc-cygwin).
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 John W. Eaton.
[..]
Report bugs to <address@hidden>.
>> p_
error: `lt' undefined near line 35 column 14
error: evaluating binary operator `&' near line 35, column 13
error: if: error evaluating conditional expression
error: evaluating if command near line 35, column 3
error: called from `stem' in file `/octave_files/stem.m'
error: near line 3 of file `/octave_files/stemx.m'
error: near line 2 of file `/octave_files/p_.m'
>>
.. I get some strange errors, after the graph of sin is plotted correctly.
Paul's file is from 2000, so it should work with my old (I know ;-)) 2.1.50.
Any hints what I am doing wrong or what is going wrong and what to do are very
welcome.
Sincerely Wolfgang
--
Staedtisches Gymnasium, Stockhauserstr. 13, DE-42929 Wermelskirchen (Germany)
privat: Wolfgang Lindner, Stieglitzweg 6, D-42799 Leichlingen
--
-- Here is Pauls source code:
## Copyright (C) 2000 Paul Kienzle
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
## usage: stem(x, [,y] [, linetype])
##
## Draws struts for each point, overlaid on another line type. This is
## just:
## plot(x, y, linetype, x, y, "^;;")
## but with the pointsize increased so that you can see the symbols
## clearly. By default, linetype is "o;;" so that circles are
## connected to the x-axis with struts.
##
## Note that a plot can only support one point size, so if you are
## plotting multiple plots, do stem last to keep large points.
##
## Example
## t=0:0.1:2*pi; x=sin(t); idx=1:4:length(t);
## plot(t,x,"r-+;sin(x);"); hold on
## stem(t(idx), x(idx),"bo;struts;"); hold off
function stem(x, y, linetype)
if nargin < 1 || nargin > 3
usage("stem(x [, y] [, linetype])");
endif
if nargin < 2, linetype=y=[]; endif
if nargin < 3, linetype=[]; endif
if isstr(y)
linetype = y;
y = [];
endif
if isempty(linetype), linetype="o;;"; endif
## scan the linetype parameter to see if a colour has been specified
colour = '1'; title=0; ignoredigit=0;
for i=1:length(linetype)
if linetype(i) == ';'
title = 1-title;
elseif !title
if !isempty(findstr("rgbmcw",linetype(i)))
colour = linetype(i);
ignoredigit=1;
elseif !isempty(findstr("0123456789",linetype(i)))
if !ignoredigit, colour = linetype(i); endif
ignoredigit=1;
endif
endif
endfor
unwind_protect
eval(sprintf("gset pointsize %d",2-min(2,fix(length(x)/100))));
gset xzeroaxis
if isempty(y)
plot(x, linetype, x, [colour, "^;;"]);
else
plot(x, y, linetype, x, y, [colour, "^;;"]);
endif
unwind_protect_cleanup
gset pointsize 1
gset noxzeroaxis
end_unwind_protect
endfunction
%!demo
%! t=0:0.1:2*pi; x=sin(t); idx=1:4:length(t);
%! plot(t,x,"+r-;sin(x);"); hold on;
%! stem(t(idx), x(idx),"bo;struts;"); hold off;
- using stem (pK),
Wolfgang Lindner <=