我有一個數據序列。所以我想繪製由於窗口長度滑動窗口內的數據。 請幫助我。如何在matlab上創建信號滑動窗口
其實數據來自幀的均值和方差。所以我想繪製滑動窗口內的均值和方差。另外我不能在Matlab上創建滑動窗口。
我有一個數據序列。所以我想繪製由於窗口長度滑動窗口內的數據。 請幫助我。如何在matlab上創建信號滑動窗口
其實數據來自幀的均值和方差。所以我想繪製滑動窗口內的均值和方差。另外我不能在Matlab上創建滑動窗口。
所以,如果我正確理解你,你想改變x軸限制的情節。使用xlim
的,例如:
a=1:10;
plot(a)
xmin = 5;
xmax = 7.6;
xlim([xmin xmax])
,或者如果你想有一個固定的大小,你可以xlim([xmin xmin+window])
等等
我的做法將是一個窗口,
a = randi(100,[1,50]); % My sequence
win_width = 10; %Sliding window width
slide_incr = 1; %Slide for each iteration
numstps = (length(a)-win_width)/slide_incr; %Number of windows
for i = 1:numstps
mean_win(i) = mean(a(i:i+win_width)); %Calculation for each window
end
plot(mean_win)
有可能做更好的方法..
僅供參考,您可以通過'mean_win = conv(a,ones(1,win_width)/ win_width)計算沒有循環的平均值,但這不是OP想要的(請參閱其他答案的評論) – bla 2013-02-15 09:16:37
對於我所檢查的,numstps應該加1,for循環中的win_width應該減1。有人可以確認嗎? – 2013-08-28 15:08:57
這就是我一直這樣做(從2滑動窗口代碼改編)。你可以計算出你想要的平均值和方差。
T = 25; % Window Size
K = size(data,1) - T; % Number of repetitions
for i = 1:K
window = data(i:i+T-1,:);
% Mean and Variance Calculations here
% Plotting here
% call 'drawnow' for incremental plotting (animation)
end
是你的信號1D還是2D? – bla 2013-02-15 08:17:48
1D平均值和方差來自圖像幀,所以我一個接一個地繪製, – Binja 2013-02-15 08:20:53
術語滑動窗口是誤導性的,而OP只想顯示\處理他已有的部分數據,即不需要計算。 – bla 2013-02-15 09:00:53