Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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!

share|improve this question
    
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. –  Kuba Aug 27 '13 at 7:40
    
@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. –  NutCase Aug 27 '13 at 9:45

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer
    
@Nasser- Thanks..:) –  NutCase Aug 27 '13 at 9:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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