How to smooth a curve with movmean with consideration of the start and end of an array?

조회 수: 3 (최근 30일)
Hello.
I am trying to smooth out a curve with movmean.
My current code looks like this:
Start_i_len = 8;
smooth_offset = cell(Start_i_len, 1);
for i = 1:1:Start_i_len
smooth_offset{i} = movmean(Offset_itpl_mean{i}, 301);
end
The cell array contains 8 cells, with each consisting of 8192 values. What I want to do is, as it samples 301 values, I want it to connect the beginning and the end of the array (If that makes sense). So that when it smoothes out the values at the nearing the end of the array, it does so with consideration of the values at the start of the array and vice versa. Any ideas on how to do it?

답변 (1개)

Matt J
Matt J 2022년 3월 16일
편집: Matt J 2022년 3월 16일
k=ones(1,301); k(8192)=0;
for i = 1:1:8
tmp=fwd.Offset_itpl_mean{i}(:).';
tmp=ifft(fft(tmp).*fft(k),'symmetric');
fwd.smooth_offset{i} = tmp;
end
  댓글 수: 4
Michael Arvin
Michael Arvin 2022년 3월 16일
I tried it and it is now 1x8192, but the values inside are very different from the original values of Offset_itpl_mean{} when I plot it. I did attach a mat file the question for the value of Offset_itpl_mean{}. If you have any other solution to it, I'd greatly appreciate it. Thanks!
Matt J
Matt J 2022년 3월 16일
편집: Matt J 2022년 3월 16일
load save1
k=ones(1,301)/301; k(8192)=0; k=circshift(k,-150);
for i = 1:1:8
tmp=Offset_itpl_mean{i}(:).';
tmp=ifft(fft(tmp).*fft(k),'symmetric');
smooth_offset{i} = tmp;
end
plot(Offset_itpl_mean{i}); hold on
plot(smooth_offset{i}); hold off

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

카테고리

Help CenterFile Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by