Tips for life, tips for tech

When extract data from a simulation, maybe sometimes we have too much data and we don’t really need all data point, so these questions may pop out:

  • How to make data less?

  • How to plot every 5 data point.

Let me explain, for example we have (x,y) data in column A and B, each column has 1000 data point and we want to plot/mahe chart for only 1st,5th,10th data point, so here is what we need to do:

  • In column C, input this function
    =mod(row(A1),5)

    The function row() will return the number of the line that the cell belong to, so in A1, row A1 will return 1.
    The function mod() will return the modulus of, for in stance mod(5,2), 5 divide by 2, is 3.
    So the function mentioned above will return from top to bottom the sequence 0,1,2,3,4,0,1…..

Now create an auto filter of that data, and criteria should be the column C, if you want to plot only the line 2, choose it 2 for example.
That’s it. Pretty easy. I’ll find a way to plot in Matlab too.

Update: For matlab it very easy.
For example we have x and y as the arrays. And we want ot plot only every 5 pairs of the data set.
We do like this:

x1=x[1:5:end];
y1=y[1:5:end];
plot(x1,y1)

Reply in English

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Tag Cloud

%d bloggers like this: