how to design a moving window? which has to move sample by sample in simulink

2 ビュー (過去 30 日間)
harish bharadwaj
harish bharadwaj 2011 年 6 月 1 日
hi,
i have converted analog signal to digital using ADC, now i have to apply a moving window to this incoming digital signal and the width of the window is 1 cycle i.e 80 samples.... please help me regarding this
  1 件のコメント
Fangjun Jiang
Fangjun Jiang 2011 年 6 月 1 日
Assume you have 1000 samples of data, you want to apply a rolling window of 80 samples at a time, what type of processing do you want to do? average, filtering? Please specify.
Also, consider Matlab. Depending on your task, sometimes Matlab is more suitable than Simulink for the job.

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

回答 (2 件)

Fangjun Jiang
Fangjun Jiang 2011 年 6 月 2 日
Here is a quick and easy way to do it in Matlab.
a=0:0.1:100;
WindowWidth=80;
b=sin(a);
c=abs(b);
d=zeros(size(b));
d(1)=sum(c(1:WindowWidth));
for i=2:(numel(a)-WindowWidth+1)
d(i)=d(i-1)-c(i-1)+c(WindowWidth+i-1);
end
figure(1);plot(b);
figure(2);plot(d);

Sean de Wolski
Sean de Wolski 2011 年 6 月 2 日
doc conv
Edit for Fangjun:
isclose = @(x,y)isequal(size(x),size(y))&&all(abs(x-y)<10^-5)
cway = conv(c,ones(1,80),'valid'); %other shapes if wanted (doc conv)
isclose(d(1:end-79),cway) %throw away your end 80 zeros
ans =
1
  4 件のコメント
Sean de Wolski
Sean de Wolski 2011 年 6 月 3 日
conv!
Fangjun Jiang
Fangjun Jiang 2011 年 6 月 3 日
Thanks, Sean!
@Harish, consider using the conv() function if you want the sum has a nice ramp up and ramp down.

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

カテゴリ

Help Center および File ExchangeSimulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by