sorting a timer in matlab -


ok seems simple problem, having problem have timer each data set resets improperly , result timing gets mixed. ideas correct it? without losing data. example

timer col ideally should be

timer , mine reads
1 3
2 4
3 5
4 6
5 1
6 2

how change colum 2 or make new colum reads colum 1 without changing order of ther rows have data example file lengths 86000 long , have missing timers not want miss , imples no data period of time.

thanks

edit: not want change other columns. coulm 1 gps counter , not sync comp timer due other issues. want change row 1 such goes high low without effecting other rows. take care of missing pts ( if did not care missing pts simple n=1: max work.

missing data in case indicated missing timer. example have 4,5,8,9 missing 6,7

ok let me try edit agian 8600x 80 matrix of data: timer 1 row should go 0 8600 timer starts @ odd times , have start of data middle , lets 3400, in middle of day timer goes 0 , 1. other rows fine. need 2 plot other sets based on timer time. cannot use t= 1:length(file) ignores missed time stamps ( timers )

for example data reads

timer , mine reads
1 3
2 4
3 5
4 8
5 9
8 1
9 2

so u can see time stamps 6,7 missing. if used n=1:length(file) have got 1 2 3 4 5 6 7 wrong want 1 2 3 4 5 8 9

without changing order of other rows , cannot use sort whole file.

i assume following problem

data says

3 100 4 101 5 102 nan 0 1 104 2 105 

you want

1 100 2 101 3 102 nan 0 4 104 5 105 

i'd solve problem this:

%# create test data data = [3 100     4 101     5 102     nan 0     1 104     2 105];  %# find rows (if missing data indicated zeros, use  %# goodrows = data(:,1) > 0; goodrows = isfinite(data(:,1));  %# count rows ngoodrows = sum(goodrows);  %# replace first column sequential numbers, in rows data(goodrows,1) = 1:ngoodrows;  data =       1   100      2   101      3   102    nan     0      4   104      5   105 

edit 1

maybe understand question time

data says

4 101 5 102 1 104 2 105 

you want

1 4 101 2 5 102 4 1 104 5 2 105 

this can achieved following way

%# test data data = [4 101     5 102     1 104     2 105];  %# use sort correct order of numbers , add left of data out = [sort(data(:,1)),data]  out =       1     4   101      2     5   102      4     1   104      5     2   105 

edit 2

note out result solution in edit 1

it seems want plot data there no entry missing values. 1 way make plot dots - there won't dot missing data.

plot(out(:,1),out(:,3),'.') 

if want plot line interrupted, have insert nans out

%# create outnan, has nan-rows missing entries outnan = nan(max(out(:,1)),size(out,2)); outnan(out(:,1),:) = out;  %# plot plot(out(:,1),out(:,3)) 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -