0
$\begingroup$

I have measurements from two tablet sensors. The first sensor measures the touch pressure applied to the tablet and the second sensor is the acceleration of the tablet (in z direction). The sensor data are stored in csv files where the first column contains the timestamp (in milliseconds) and the second column contains the sensor data (either touch pressure or acceleration). I have uploaded the two sensors files: https://1drv.ms/f/s!AlkQuYgB1McYgudFUrpMzMopUr2wVw

Now I would like to investigate if there exists a correlation between touch pressure and acceleration. I could just calculate the cross-correlation or plotting the pressure against the acceleration (and perhaps add a linear regression line).

The problem is that the acceleration measurements have a more or less constant sampling rate but for the pressure I have not a constant sampling rate. That means that the number of measurements for acceleration and pressure is also not the same (and the timestamps are therefore also not the same).

How can I still calculate the correlation and producing a accleration vs. pressure plot? I thought about a interpolation of the accleration measurements to the timestamps of the pressure readings but I don't know what type of interpolation to use (linear or cubic seems not to be right). Perhaps there is a better way of doing it.

Here are the plots of the two sensors:

enter image description here

enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

If you are using MATLAB, there is a built in object type, called

timeseries

, that is very useful for this sort of problem.

>    Methods for class timeseries:
> 
> addevent              getabstime            gettsbeforeatevent    mean
> pvset                 times                  addsample            
> getdatasamples        gettsbeforeevent      median               
> rdivide               timeseries             append               
> getdatasamplesize     gettsbetweenevents    min                  
> resample              tsprops                createTstoolNode     
> getinterpmethod       hasduplicatetimes     minus                 set 
> utArithCommonData      delevent              getprop              
> idealfilter           mldivide              setabstime           
> utArithCommonOutput    delsample             getqualitydesc       
> init                  mode                  setinterpmethod      
> utArithCommonTime      detrend               getsamples            iqr
> mrdivide              setprop               utChkforSlashInName   
> display               getsampleusingtime    isequal              
> mtimes                setuniformtime        utGetEventTime         eq 
> gettsafteratevent     isequalwithequalnans  plot                  std 
> utStatCalculation      filter                gettsafterevent      
> ldivide               plus                  sum                   var 
> get                   gettsatevent          max                  
> pvget                 synchronize           
> 
> Static methods:
> 
> loadobj               tsChkTime             tsgetrelativetime

The setuniformtime method will do the interpolation for you. The other methods are often useful.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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