3
$\begingroup$

I have text file with data in 2 columns. I have imported it using the following line

c = Import["ab", "Table"];

This text file has a large amount of data, and I need only a certain range. What I mean is, if my data runs for example from -10 to +10, I need only from -5 to +5 and its corresponding values.

So I naively tried this

Plot[c, {-5, 5}]

which is clearly wrong, and its little wonder that I am getting an error message.

Not sure what to do. Please help!

$\endgroup$
  • $\begingroup$ Hello, your approach is no so bad. But assuming this data is a coordinate list you have to use ListPlot and with given PlotRange it will work. However, it does not affect your data but only the plotted area. $\endgroup$ – Kuba Aug 27 '13 at 7:40
  • $\begingroup$ @Kuba Thanks! I tried this PlotRange -> { {-5, 5}, {-10, 10} } and it works. Turns out with the first set ie {-5, 5} I can manipulate the x axis,and with the second, the y axis. $\endgroup$ – NutCase Aug 27 '13 at 9:45
2
$\begingroup$

You can use Select like this:

data = Table[{i, RandomReal[1]}, {i, 10}]

Mathematica graphics

filtered = Select[data, (.1 < #[[2]] < .5) &]

Mathematica graphics

ListLinePlot[filtered, Mesh -> All, MeshStyle -> Red]

Mathematica graphics

or

ListLinePlot[{data, filtered},PlotLegends -> {"original", "filtered"}, Joined -> True]

Mathematica graphics

$\endgroup$
  • $\begingroup$ @Nasser- Thanks..:) $\endgroup$ – NutCase Aug 27 '13 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.