Skip to main content
improve code for importing the data
Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489

If I understand the problem correctly, we just need to extract the path from StreamPlot, don't we?

If you have difficulty in accessing the data in dropbox in the question, try the following:

previousCell[] := 
 Cells@EvaluationNotebook[] /. {___, prev_, EvaluationCell[], ___} :> 
   ToExpression@First@NotebookRead@prev

Import["http://halirutan.github.io/Mathematica-SE-Tools/decode.m"]["http://i.stack.imgur.\
com/eDzXT.png"]

The following part of code should be placed in a new cell under the previous code:

SelectionMove[EvaluationNotebook[], Previous, Cell, 1];
dat = Uncompress@previousCell[];Uncompress@First@First@NotebookRead@EvaluationNotebook[];
NotebookDelete@EvaluationNotebook[];

func = Interpolation@dat;

{vx, vy} = Function[{x, y}, #] & /@ Grad[func[x, y], {x, y}];

begin = {180.0, 179.99};
end = {124.5, 124.49};

plot = StreamPlot[{vx[x, y], vy[x, y]}, {x, #, #2}, {y, #3, #4}, StreamPoints -> {begin},
     StreamStyle -> "Line", Epilog -> Point@{begin, end}] & @@ Flatten@func["Domain"]

Mathematica graphics

path = Cases[Normal@plot, Line[a_] :> a, Infinity][[1]];

ListPlot3D@dat~Show~Graphics3D@Line[Flatten /@ ({path, func @@@ path}\[Transpose])]

Mathematica graphics

If I understand the problem correctly, we just need to extract the path from StreamPlot, don't we?

previousCell[] := 
 Cells@EvaluationNotebook[] /. {___, prev_, EvaluationCell[], ___} :> 
   ToExpression@First@NotebookRead@prev

Import["http://halirutan.github.io/Mathematica-SE-Tools/decode.m"]["http://i.stack.imgur.\
com/eDzXT.png"]

The following part of code should be placed in a new cell under the previous code:

dat = Uncompress@previousCell[];

func = Interpolation@dat;

{vx, vy} = Function[{x, y}, #] & /@ Grad[func[x, y], {x, y}];

begin = {180.0, 179.99};
end = {124.5, 124.49};

plot = StreamPlot[{vx[x, y], vy[x, y]}, {x, #, #2}, {y, #3, #4}, StreamPoints -> {begin},
     StreamStyle -> "Line", Epilog -> Point@{begin, end}] & @@ Flatten@func["Domain"]

Mathematica graphics

path = Cases[Normal@plot, Line[a_] :> a, Infinity][[1]];

ListPlot3D@dat~Show~Graphics3D@Line[Flatten /@ ({path, func @@@ path}\[Transpose])]

Mathematica graphics

If I understand the problem correctly, we just need to extract the path from StreamPlot, don't we?

If you have difficulty in accessing the data in dropbox in the question, try the following:

Import["http://halirutan.github.io/Mathematica-SE-Tools/decode.m"]["http://i.stack.imgur.\
com/eDzXT.png"]
SelectionMove[EvaluationNotebook[], Previous, Cell, 1];
dat = Uncompress@First@First@NotebookRead@EvaluationNotebook[];
NotebookDelete@EvaluationNotebook[];

func = Interpolation@dat;

{vx, vy} = Function[{x, y}, #] & /@ Grad[func[x, y], {x, y}];

begin = {180.0, 179.99};
end = {124.5, 124.49};

plot = StreamPlot[{vx[x, y], vy[x, y]}, {x, #, #2}, {y, #3, #4}, StreamPoints -> {begin},
     StreamStyle -> "Line", Epilog -> Point@{begin, end}] & @@ Flatten@func["Domain"]

Mathematica graphics

path = Cases[Normal@plot, Line[a_] :> a, Infinity][[1]];

ListPlot3D@dat~Show~Graphics3D@Line[Flatten /@ ({path, func @@@ path}\[Transpose])]

Mathematica graphics

Source Link
xzczd
  • 68.4k
  • 9
  • 174
  • 489

If I understand the problem correctly, we just need to extract the path from StreamPlot, don't we?

previousCell[] := 
 Cells@EvaluationNotebook[] /. {___, prev_, EvaluationCell[], ___} :> 
   ToExpression@First@NotebookRead@prev

Import["http://halirutan.github.io/Mathematica-SE-Tools/decode.m"]["http://i.stack.imgur.\
com/eDzXT.png"]

The following part of code should be placed in a new cell under the previous code:

dat = Uncompress@previousCell[];

func = Interpolation@dat;

{vx, vy} = Function[{x, y}, #] & /@ Grad[func[x, y], {x, y}];

begin = {180.0, 179.99};
end = {124.5, 124.49};

plot = StreamPlot[{vx[x, y], vy[x, y]}, {x, #, #2}, {y, #3, #4}, StreamPoints -> {begin},
     StreamStyle -> "Line", Epilog -> Point@{begin, end}] & @@ Flatten@func["Domain"]

Mathematica graphics

path = Cases[Normal@plot, Line[a_] :> a, Infinity][[1]];

ListPlot3D@dat~Show~Graphics3D@Line[Flatten /@ ({path, func @@@ path}\[Transpose])]

Mathematica graphics