Plot Values, why boudary values seems to have peak? I tried to remove the extreme value but the situations doesn't change

1 ビュー (過去 30 日間)
Andrea Ciufo
Andrea Ciufo 2017 年 3 月 5 日
回答済み: Image Analyst 2017 年 3 月 6 日
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:
  1. Remove the first and the final 750 samples (approximatly 14" before and after)
  2. 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')
  1 件のコメント
David Goodmanson
David Goodmanson 2017 年 3 月 6 日
Hello Andrea, Actually you appear to be making progress, and perhaps you have not cut out enough time samples yet. How large is time array all together, and have you considered plotting out, say, just the part from t>6e4 to the end and using zoom?

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2017 年 3 月 6 日
Try taking the mean and standard deviation and if any are outliers, remove them or replace them with the mean
meanValue = mean(signal);
sd = std(signal);
outliers = abs(signal - meanValue) > 3 * sd;
signal(outliers) = {}; % Remove outliers.
% Or alternatively
%signal(outliers) = meanValue;

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by