I am trying to plot a vector field from data file. I can put the data into file in any way, but for now data file contains information in this form:
x y Fx Fy
where Fx and Fy are x and y components of a vector.
Any ideas how to plot it?
I am trying to plot a vector field from data file. I can put the data into file in any way, but for now data file contains information in this form:
x y Fx Fy
where Fx and Fy are x and y components of a vector.
Any ideas how to plot it?
Given a a file vector.txt in an appropriate location containing exactly eight lines
1 1 2 3
1 2 5 3
1 3 4 5
1 4 2 2
2 1 3 3
2 2 5 6
2 3 4 1
2 4 1 4
(without any additional white space anywhere)
and a fresh Mathematica notebook containing
datain = Partition[ToExpression[ "{" <>
StringReplace[Import["vector.txt"],
RegularExpression["\\s"] -> ","] <> "}"], 4];
arrow = Map[Arrow[{Take[#, 2], Take[#, 2] + Drop[#, 2]}] &, datain];
Graphics[arrow]
Evaluate that and a small collection of arrows appears in the notebook.