필터 지우기
필터 지우기

Real Time Data Store in Inf Array

조회 수: 1 (최근 30일)
Can Burak Kavuncuoglu
Can Burak Kavuncuoglu 2019년 7월 17일
답변: David K. 2019년 7월 17일
I have MPU6050 sensor. I had codes and I store in a 1x1 double array. But now I wanna filter it but I cant do it for real time. Because my filter needs at least 3 sample for filtering. And you know, in real time you need filter all datas 1 by 1.
After all I need to store my datas in zeros array. How can store real time "Acc_Mag" datas in "accmag = zeros (1,10000);" array?
  댓글 수: 2
dpb
dpb 2019년 7월 17일
You'll have to keep an index variable to point to the next point in the array for longer time series.
Can Burak Kavuncuoglu
Can Burak Kavuncuoglu 2019년 7월 17일
Can you explain it with function, please? I have same idea but its just a idea. I tried to do it but still i have same error.
Error using filtfilt>getCoeffsAndInitialConditions (line 182)
Data length must be larger than 3 samples.

댓글을 달려면 로그인하십시오.

답변 (1개)

David K.
David K. 2019년 7월 17일
If I understand correctly what you want and a guess at how you are formatting it.
Pointer = 1;
window = sizeFilter % However big you want the filter
while (running)
data = newData; % new 1x1 double
window(Pointer) = data;
% if order matters for your filter you can also use the pointer as indication for that
filteredData = filter(window);
Pointer = Pointer+1;
% Loop pointer
if Pointer >window
Pointer = 1;
end
end
Unless all you want to do is save the initial data. Then that is simply
accmag = zeros(1,10000);
Pointer = 1;
while(running)
data = newData;
accmag(Pointer) = data;
Pointer = Pointer + 1;
end

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by