When i plot my deta on the boundary values i see a sort of peak, that i can't undestand.
I plot my accelerometer data, in this case from the Z axis, in a static condition (so roughly 9,81m/s^2).
I though that this peaks could be caused when i turn on/off my device so i decided to make two different tests:
- Remove the first and the final 750 samples (approximatly 14" before and after)
- Remove the first and the final 1000 samples (approximatly 20" before and after)Here the plot after removing 750 samples
Here the plot after removing 1000 samples
I don't know if there is a problem with my code:
filename= uigetfile ('.txt'); fileID = fopen (filename); logmpu6050 =csvread(filename); fclose (fileID); %Starting creating the specific Vectors
%Record Time in millisecond
time=logmpu6050(:,1); %The x y z are converted to m/s^2
confactor=19.6/32768; ax=logmpu6050(:,2); confactor=19.6/32768; ax=ax*confactor; ay=logmpu6050(:,3); ay=ay*confactor; az=logmpu6050(:,4); az=az*confactor; %Define the sample rate subtracting from Sampletime i+1 Sampletime i
n=length(time); for i = 1:n-1 samplerate(i) = time(i+1)-time(i); end; %I try to define the best frequency for "resample" function based on mode and median value
%I will not use average to avoid conditioning due to extreme value
f1=mode(samplerate); f2=median(samplerate); %resampling at time mode record frequency
%note: the first output is the y value of the resampled signal
%the second is the instants that correspond to the resampled signal
[azf1res,timeintf1]= resample(az,time,f1); %resampling at time median record frequency
[azf2res,timeintf2]= resample(az,time,f2); figure plot(timeintf1,azf1res) title('Accelerazione Z+ ricampionatata secondo il valore mediano della frequenza') ylabel('Acc m/s^2') xlabel('Tempo') figure plot(timeintf2,azf2res) ylabel('Acc m/s^2') xlabel('Tempo') %We clean the data removing the extreme value time value
%We are removing the moments when we turn on and turn off the device
%cl means cleaned
azf1rescl= azf1res(750:end-750); timeintf1cl= timeintf1(750:end-750); azf2rescl=azf2res(750:end-750); timeintf2cl=timeintf1(750:end-750); figure plot(timeintf1cl,azf1rescl) title('Accelerazione Z+ ricampionatata secondo il valore mediano della frequenza, rimossi i valori t di accensione e spegnimento') ylabel('Acc m/s^2') xlabel('Tempo') figure plot(timeintf2cl,azf2rescl) title('Accelerazione Z+ ricampionatata secondo il valore modale della frequenza, rimossi i valori t di accensione e spegnimento') ylabel('Acc m/s^2') xlabel('Tempo')
Best Answer