0
$\begingroup$

This question already has an answer here:

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.

$\endgroup$

marked as duplicate by Michael E2, ciao, Yves Klett, Kuba, m_goldberg Jul 2 '14 at 10:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Browse other questions tagged or ask your own question.