This post may win the "most pedestrian" award. I'd like to add a curve to a plot of the form f(mod(t,period)) and I don't see a command equivalent to "mod" (or "rem") in the programmer's reference. The following works as a substitute:
atan2(sin(t*2*PI/period),cos(t*2*PI/period))
but that is a lot to type into the "plot what" dialog window, when all I really want is "mod(t,period)". Suggestions?
command line for "mod" or "rem"?
-
- Site Admin
- Posts: 6300
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: command line for "mod" or "rem"?
You're looking for %.
for i=0,10 print i%3
It's in the NEURON Book, but not in Kernighan & Pike's original definition of hoc in "The UNIX Programming Environment," so you'll get a pass from them.
for i=0,10 print i%3
It's in the NEURON Book, but not in Kernighan & Pike's original definition of hoc in "The UNIX Programming Environment," so you'll get a pass from them.
Re: command line for "mod" or "rem"?
Many thanks, Ted! Sorry I didn't know that one -- it doesn't appear under the general "math" entry
http://www.neuron.yale.edu/neuron/stati ... .html#math
http://www.neuron.yale.edu/neuron/stati ... .html#math
-
- Site Admin
- Posts: 6300
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: command line for "mod" or "rem"?
I don't think any of the operators is listed in the Programmer's Reference--a stunning omission. We're doing a big rewrite of the Programmer's Reference, and this is one of the items on our to-do list.