How do I filter my data points without using smoothdata?

I have 2 variables, t and y, which are both vectors. What I want to do is smooth the data so that, for example, if t is a 10x1 vector, it becomes a 5x1 vector comprising an average of the data points around it. How do I go about this without using the smoothdata function?
Thank you very much and kind regards,
Tom

댓글 수: 2

I'm sure there's a better way, but you could do this manually using a for loop and interpolation.
t2 = linspace(t(1),t(end),5);
for i = 1:5;
y2(i) = interp1(t,y,t2(i));
end
Note: Interpolation without smoothing or lowpass filtering first could result in aliasing.

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

답변 (2개)

Chad Greene
Chad Greene 2018년 12월 11일

0 개 추천

What about movmean to smooth the data, then interp1 to pick out the 5 points you want?

댓글 수: 2

Is movmean part of the signal processing toolbox??? I'm not allowed to use any functions from there
No, it's part of base MATLAB. If you get help on any function, it will tell you what toolbox it's in, if any.

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

Image Analyst
Image Analyst 2018년 12월 12일
편집: Image Analyst 2018년 12월 12일
You could use conv() to smooth y.
windowWidth = 5;
kernel = ones(1, windowWidth) / windowWidth;
smoothedY = conv(y, kernel, 'valid'); % conv() is in base MATLAB.
Do NOT smooth t, for obvious reasons.

카테고리

도움말 센터File Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

태그

질문:

2018년 12월 11일

편집:

2018년 12월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by