Re: [Q] Programming & "Not Floating Point Number" Error
- To: mathgroup at smc.vnet.net
- Subject: [mg3163] Re: [mg3133] [Q] Programming & "Not Floating Point Number" Error
- From: penny at edu-suu-scf.sc.suu.edu (Des Penny)
- Date: Fri, 9 Feb 1996 03:02:28 -0500
- Sender: owner-wri-mathgroup at wolfram.com
>I have a Mma question that I hope someone out there can help me with. I
>recently started using Mma for a class and have had a hard time
>"programming" with it. Here is the script/program that i wrote:
>
>--
>epsilon = .01
>gamma = 7
>dt = .125
>stim = 0
>
>y0 = -.5
>w0 = 0.0
>
>For[i=0, i<50, i++,
>f = y0 * (1 - y0 *y0);
>v = y0 + (f - w0) * dt;
>w = w0 +(epsilon*(gamma*y0 - w0)) * dt;
>vee[i] = v;
>doubleu[i] = w;
>y0 = v;
>w0 = w;
>]
>
>ListPlot[{vee,doubleu}]
>---
>
>In the script above I'm essentially calculating a bunch of points
>that I want to plot (V vs. W - I had to use "vee" and "doubleu" to get it
>to work). The only way I could figure to do it was to store the numbers
>in a list and then use ListPlot[] but I can't get it right. I keep
>getting:
>
>--
>Graphics::gptn:
> Coordinate vee in {1, vee} is not a floating-point number.
>Graphics::gptn:
> Coordinate doubleu in {2, doubleu} is not a floating-point number.
>--
>
>What am I doing wrong?
>
>Thanks for the help,
>
>Noel
*****************************************************************************
Hi Noel:
This is just an addendum to the excellent reply given by Robert Knapp.
Here I show a different way to correct your code:
epsilon = .01;
gamma = 7;
dt = .125;
stim = 0;
y0 = -.5;
w0 = 0.0;
points={};
For[i=0, i<50, i++,
f = y0 * (1 - y0 *y0);
v = y0 + (f - w0) * dt;
w = w0 +(epsilon*(gamma*y0 - w0)) * dt;
AppendTo[points, {v,w}];
y0 = v;
w0 = w;
]
ListPlot[points];
Cheers,
Des Penny
==========================
Des Penny
Physical Science Dept.
Southern Utah University
Cedar City, UT 84720
VOICE: (Office): (801) 586-7708
(Home) : (801) 586-2286
FAX: (801) 865-8051
e-mail: penny at suu.edu
==========================
==== [MESSAGE SEPARATOR] ====