Useful Gibberish

Posts tagged ‘data’

Purify excel/gnumeric sheetdata

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)

Adding point to Matlab plot

Here is the code to plot a data point to a 2D diagram.

plot(x,y) %plot the line
yi=interp1(x,y,a)
% a is a real number of the
% x-axis value of the data point
hold on
plot(a,yi,'*')

For example:

x=[0:0.01:1];
y=[0:10:1000];
plot(x,y);
% Now add a data point with x=0.25
yi=interp1(x,y,0.25);
hold on;
plot(0.25,yi,'*')

Tag Cloud

%d bloggers like this: