Gait-Tracking-With-x-IMU icon indicating copy to clipboard operation
Gait-Tracking-With-x-IMU copied to clipboard

How to adjust the sampling time? (2sec and 1sec)

Open AlexWUrobot opened this issue 9 years ago • 11 comments

Because I already set "Data Output Setting" frequency from 1Hz to 512Hz but I still can not get the sample data like below Packet number Gyroscope X (deg/s) Gyroscope Y (deg/s) Gyroscope Z (deg/s) 3 -0.0625 -0.25 -0.0625 5 -0.0625 -0.25 -0.0625 6 -0.0625 0.0625 0 8 -0.375 -0.25 -0.375 9 -0.0625 0.5625 0.0625 11 -0.125 -0.125 -0.1875 12 0.125 0.5 -0.0625 I mean my Packet number can not variable intervals 5-3=2 6-5=1 8-6=2 9-8=1 Most of all, I can not run the program Matlab ERROR like below

Error in ==> Script at 111 indexSel = 2 : find(sign(time-(time(1)+initPeriod))+1,1);

AlexWUrobot avatar Jul 17 '16 16:07 AlexWUrobot

I think you should read Script code carefully, in the demo the sample time is 1/256, that mean in 1 s, there will be 256 packet received; in you demo you just change samplePeriod to 512, and do not forget change the value of startTime(s) and stopTime(s), the period time you want to use.

OceanWong1991 avatar Mar 10 '17 12:03 OceanWong1991

Thanku @OceanWong1991 . Can u please explain start time and stop time in this case?

ahmednawazkhan avatar Feb 21 '19 14:02 ahmednawazkhan

startTime and stopTime are used to frame the data so that only the period of interest is processed

xioTechnologies avatar Feb 28 '19 14:02 xioTechnologies

can u explain a litter more please

ahmednawazkhan avatar Mar 04 '19 08:03 ahmednawazkhan

Hi

I worked with this and had the same issue

I am new to matlab and programming but i think my interpretation is correct.

When you import your dataset according to the sample rate the time for each readings of data set is given by the script.

Assume like this you have 10000 readings in your csv file if your sample rate is 1/256 the first reading is given 1sec and your 10000th reading will given 256sec ( just assumptions)

Then in the script there is a start time and end time variables assume that Start time = 10 End time = 50

Then the script only use the readings between 10 and 50 seconds 0-10 and 50-256 sec are ignored

Did you understand now.

If not I can explain more.

Omegaki113r avatar Mar 10 '19 10:03 Omegaki113r

what if i want to use sample rate = 1. what does this mean and what will be the start and end time in this case? suppose i have 1000 samples

ahmednawazkhan avatar Mar 10 '19 10:03 ahmednawazkhan

As I told you I am new to this as you.

But let me get back to you in a while.

I will answer soon

Omegaki113r avatar Mar 10 '19 12:03 Omegaki113r

Despite following the advice of OceanWong and attempting to follow along with Omegaki I am receiving the same error as the above posters. I am currently working with these key assumptions:

  1. I have checked that the input units being used are the same (°/s for gyro, g for accelerometer, G for magnetometer).
  2. My sample period is 1/256, implying 256 samples per second. To me this means that packet numbers 1-256 will belong to second=1, 257-512 to second=2, etc. With 2560 packets, I would expect to have my stop time go up to 10, but if I put any number higher than 1 I get the error:

Index exceeds the number of array elements (0). Error in Script (line 113) indexSel = 1 : find(sign(time-(time(1)+initPeriod))+1, 1);

Is there anybody with a solution to the above error?

EDIT: I cannot empirically verify the 2nd assumption above since my sensor only goes up to 100 Hz (MPU9250 running at 500000 baud through Arduino Uno). Kind of looks like an error in the code but my matlab experience is limited so can't be sure.

ztrattner avatar Mar 18 '19 16:03 ztrattner

what is he trying to do with "indexSel". what is it

ahmednawazkhan avatar Mar 30 '19 08:03 ahmednawazkhan

Despite following the advice of OceanWong and attempting to follow along with Omegaki I am receiving the same error as the above posters. I am currently working with these key assumptions:

  1. I have checked that the input units being used are the same (°/s for gyro, g for accelerometer, G for magnetometer).
  2. My sample period is 1/256, implying 256 samples per second. To me this means that packet numbers 1-256 will belong to second=1, 257-512 to second=2, etc. With 2560 packets, I would expect to have my stop time go up to 10, but if I put any number higher than 1 I get the error:

Index exceeds the number of array elements (0). Error in Script (line 113) indexSel = 1 : find(sign(time-(time(1)+initPeriod))+1, 1);

Is there anybody with a solution to the above error?

EDIT: I cannot empirically verify the 2nd assumption above since my sensor only goes up to 100 Hz (MPU9250 running at 500000 baud through Arduino Uno). Kind of looks like an error in the code but my matlab experience is limited so can't be sure.

In Script.m put a break point right after time variable, then open the time variable. It should be populate with all moments of time you write in file according of your samplePeriod. So for example first value is 0(first written value) and the last value is 9(last value saved was 9 second later), you can't set stopTime grater then 9 second. This is the cause of 'indexSel' error;

IonRpd avatar Jun 06 '19 09:06 IonRpd

I am also getting the following error.

Index exceeds matrix dimensions.

Error in Script (line 109) indexSel = 1 : find(sign(time-(time(1)+initPeriod))+1, 1);

Please Help me in this regard Thank You.

MuhammadAli152 avatar Jan 02 '21 15:01 MuhammadAli152