[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using stem (pK)

From: Paul Kienzle
Subject: Re: using stem (pK)
Date: Mon, 5 Jun 2006 07:47:22 -0400

I see in your code < which looks like an html named character for "less than". I'm guessing that the m-file was cut and pasted from the web or from an email. Try again after replacing them.

        - Paul

On Jun 5, 2006, at 5:55 AM, Wolfgang Lindner wrote:

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

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>.

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

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
## 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 &lt; 1 || nargin &gt; 3
    usage("stem(x [, y] [, linetype])");
  if nargin &lt; 2, linetype=y=[]; endif
  if nargin &lt; 3, linetype=[]; endif
  if isstr(y)
    linetype = y;
    y = [];
  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);
      elseif !isempty(findstr("0123456789",linetype(i)))
        if !ignoredigit, colour = linetype(i); endif

    eval(sprintf("gset pointsize %d",2-min(2,fix(length(x)/100))));
    gset xzeroaxis
    if isempty(y)
      plot(x, linetype, x, [colour, "^;;"]);
      plot(x, y, linetype, x, y, [colour, "^;;"]);
    gset pointsize 1
    gset noxzeroaxis

%! 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;

Help-octave mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]