現在、データが半球を「反転」し、本来あるべきものの逆を記録するモーションセンサーからのエラーを検出するMATLABスクリプトに取り組んでいます。これに加えて、この「反転」プロセス中にセンサーが値を記録し続ける移行期間があります。
以下に例を示します (x 軸は時間 (サンプル)、y はセンサーからセンサーまでの距離 (インチ) です)。
私の現在の進行状況は次のとおりです。
データ エラーは抑制されていますが、残りのデータ セットとはまだ一致していません。誰かが改善する方法を提案できますか?
私のコードは次のとおりです。
%Create counter variable
n = 1;
%Find length of the matrix under test
size = length(mTest);
intVals = zeros(size,1);
for n = 1:size
%Round all of the values recorded to the nearest integer (inch)
intVals(n,1) = round(mTest(n,1));
end
%Find the mode of the integers to have a reference point against the errors
ref = mode(intVals);
%Create a sample to put the new `fixed` data into
mFix1 = zeros(size,1);
for n = 1:size
checkVal = mTest(n,1);
%If the raw value is not within an inch either side of the reference
%point check for complete wrapping by inverting the data.
if checkVal < (ref-1)
checkVal = -checkVal;
end
if checkVal > (ref+1);
checkVal = -checkVal;
end
%If the data is still outside of the range of acceptable values create
%an estimate based upon the last 3 samples
if checkVal < (ref-1) && checkVal > (ref+1)
m(1,1) = mFix1(n-3,1);
m(2,1) = mFix1(n-2,1);
m(3,1) = mFix1(n-1,1);
checkVal = mean(m);
end
%Output the data after error checking
mFix1(n,1) = checkVal;
end