0

I'm trying to write a small piece of code that will take the RHS of a first order linear ODE and return a slope field sampled at a few points. I have written:

(* Direction fields for 1st order linear equations y' = f(y,t) *)

grid = 10;

supt = 2; inft = -2; supy = 2; infy = -2;

tlist = Table[inft + n (supt - inft)/grid, {n, 0, grid}];
ylist = Table[infy + n (supy - infy)/grid, {n, 0, grid}];

Ggrid = Partition[Flatten[Outer[{#1, #2} &, tlist, ylist]], 2];

f = #1 + Exp[-2 #1] - 3 #2 &;

slopes = f[#[[1]], #[[2]]] & /@ Ggrid // N; 

slopes is a Table of function values evaluated on the 2 dimensional array Ggrid. I would like to plot a small line with the given slope at the corresponding point in Ggrid.

JEM
  • 1,165
  • 6
  • 15
  • 2
    maybe http://mathematica.stackexchange.com/questions/8841/how-can-i-plot-the-direction-field-for-a-differential-equation or http://calculuslab.deltacollege.edu/ODE/7-1/7-1-0-c-mma.html also this is useful http://stackoverflow.com/questions/8905726/how-do-i-plot-a-slope-field-using-mathematica – Nasser Jul 02 '14 at 00:10
  • 1
    See also this answer: http://mathematica.stackexchange.com/a/43174 – Michael E2 Jul 02 '14 at 00:21
  • yes, the application here is a slope field but really I'm curious how to place a prescribed miniature graphic(straight line or something else) at each point in a 2D lattice of points. Streamplot works wonderfully for this particular app. Not sure if I can edit the title of this post. – JEM Jul 02 '14 at 13:24

0 Answers0