[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Line plotting not working in an Octave 3.8.1 script
From: |
Mike Miller |
Subject: |
Re: Line plotting not working in an Octave 3.8.1 script |
Date: |
Thu, 12 Jun 2014 12:44:01 -0400 |
On Thu, Jun 12, 2014 at 08:30:16 -0700, fbarbuto wrote:
> Here it is:
>
> http://trash.ctdo.de/a/586hekjm938
You are misunderstanding how the plot function operates, and perhaps
more fundamentally the way that operators and functions work with
vectors.
Your script does not plot a line, it plots a series of points on the
same axis. Here is the relevant part of your script inline:
> for x=1:5
> arg = x/20.0
> t = Talbot(arg, 32)
> plot(arg,t,'bd',arg, sqrt(arg)*besselj(1, 2.0*sqrt(2.0*arg)),'r-');
> hold on;
> endfor
This loop does not create a line connecting each of the pairs of
points you are passing to the plot function. If you pass two pairs of
vectors to plot, it will plot a line. If you pass only scalars it will
plot a point.
Instead of looping over the points, you want to collect all values
into vectors to pass to a single call to plot to get a line.
Better still would be if your Talbot function operated on arg as a
vector argument. The besselj function already does. For example try
this:
arg = [1:5]/20;
plot (arg, sqrt (arg) .* besselj (1, 2 * sqrt (2 * arg)), "r-");
--
mike
- Line plotting not working in an Octave 3.8.1 script, Fausto Arinos de A. Barbuto, 2014/06/11
- Re: Line plotting not working in an Octave 3.8.1 script, Ben Abbott, 2014/06/11
- Re: Line plotting not working in an Octave 3.8.1 script, Fausto Arinos de A. Barbuto, 2014/06/11
- Re: Line plotting not working in an Octave 3.8.1 script, Andreas Weber, 2014/06/12
- Re: Line plotting not working in an Octave 3.8.1 script, Andreas Weber, 2014/06/12
- Re: Line plotting not working in an Octave 3.8.1 script, fbarbuto, 2014/06/12
- Re: Line plotting not working in an Octave 3.8.1 script, Andreas Weber, 2014/06/12
- Re: Line plotting not working in an Octave 3.8.1 script, fbarbuto, 2014/06/12
- Re: Line plotting not working in an Octave 3.8.1 script, fbarbuto, 2014/06/12
- Re: Line plotting not working in an Octave 3.8.1 script,
Mike Miller <=
- Re: Line plotting not working in an Octave 3.8.1 script, Fausto Arinos de A. Barbuto, 2014/06/12
Re: Line plotting not working in an Octave 3.8.1 script, Dmitri A. Sergatskov, 2014/06/11