data extraction with time points from a sensor device

7 views (last 30 days)
I am using a body worn sensor to measure balance in patients, the sensor starts to measure from the time it is turned on. I am measuring a series of tests of 30 seconds intervals with breaks in between for the patients and i am using an android app to record the exact time (time of the day)the respective test has been measured. My question is how can i synchronize and extract the data only from those 30 seconds test measurements with the time i recorded in my android app. please help..

Answers (2)

dpb
dpb on 15 Jul 2014
I'd guess w/o knowing precisely how the app works the easiest would simply be to read all the data and turn into Matlab datenum s. Then select from a start/end time also in datenum format with ordinary math operations.
A "syntactic sugar" function I use a lot for such selections is
function flg=iswithin(x,lo,hi)
% returns T for values within range of input
% SYNTAX:
% [log] = iswithin(x,lo,hi)
% returns T for x between lo and hi values, inclusive
flg= (x>=lo) & (x<=hi);
that allows one to write at top level
x=data(iswithin(dn,dn1,dn2),:);
to return the desired data where dn is a vector of datenum and data is the array of data values of the same length.
  1 Comment
Surendar Devan
Surendar Devan on 31 Jul 2014
hello dpb,
Thank you for your reply. I can understand your script but i am not sure whether it works.
x=data(iswithin(dn,dn1,dn2),:); in this case dn has a limit and so on.
that what i am confused. please give me a answer if you have

Sign in to comment.


Star Strider
Star Strider on 15 Jul 2014
How are the time data in the sensor stored? If it starts from zero each time it is turned on and you know the exact time of day it was turned on, then I would add the sensor times to the initial time of day to get the sensor times in terms of time of day.
If the sensor has its own time of day clock, you need to calibrate it at the outset with your android app times. You can make the necessary corrections later.
  5 Comments
dpb
dpb on 31 Jul 2014
Explain what it is we're looking at and what you want/need and this real clock time from somewhere else...
Remember we only know what is on the screen; we don't have the app or the device or have any real klew of what you're even trying to accomplish. That's all patently clear to you, but not to any of us here...we "know nuthink!" as per Stg Schultz.
Star Strider
Star Strider on 31 Jul 2014
You will have to save the app data in a text file, or manually create strings from them as I did here. In any event, you can use textscan to recover the data:
x = {'1;-1;ROM_Open_1;9 36 21;9 36 52'
'2;-1;ROM_Open_2;9 37 15;9 37 46'
'3;-1;ROM_Open_3;9 38 12;9 38 43'
'4;-1;ROM_Closed_1;9 39 18;9 39 49'
'5;-1;ROM_Closed_2;9 40 40;9 41 11'
'6;-1;ROM_Closed_3;9 42 7;9 42 39'
'7;-1;SL_Left_1;9 43 31;9 43 44'
'8;-1;SL_Right_1;9 44 4;9 44 26'
'9;-1;SL_Left_2;9 44 41;9 44 58'
'10;-1;SL_Right_2;9 45 13;9 45 35'
'11;-1;Foam_Surface_1;9 46 45;9 47 16'
'12;-1;Foam_Surface_2;9 47 52;9 48 24'};
for k1 = 1:size(x,1)
d{k1} = textscan(x{k1}, '%d %d %s %d %d %d %d %d %d', 'delimiter',';');
tc(k1,:) = d{k1}(4:9);
end
td = cell2mat(tm);
The tc array is a cell array of the start and end times, td is the double array of those same data.

Sign in to comment.

Categories

Find more on Data Import and Export in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!