Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How to vectorise the filter function with multiple window-sizes?

1 回表示 (過去 30 日間)
Sven Koerner
Sven Koerner 2017 年 5 月 10 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
The task is to calculate the maximum of a moving rms-value of a signal, which is available with a constant timestep dt. So the signal has the length of T*dt and the RMS-value shall be calculated for a period tau=1*dt, tau=2*dt, tau=3*dt, ... tau=T*dt. At the end of this calulation the max of the moving rms value shall be selected. Actually I use the filter-function in a for-loop, but maybe it is possible to vectorise the calculation?
  2 件のコメント
Jan
Jan 2017 年 5 月 11 日
Please post your code. This would allow to suggest improvements, which is much easier than creating the function from scratch based on your description.
Sven Koerner
Sven Koerner 2017 年 5 月 12 日
Hi Jan,
please see below:
function [tau, werte_eff_H ] = twa_stat_2(signal)
% any signal-vector;
signal_eff = signal.^2; % To calculate the RMS-Values
no_value = size(signal,1);
tau = (1:1:no_value)';
werte_eff_H = NaN(size(signal,1)+1, no_value); % Preallocation
for i=1:size(tau,1)
zb_werte_eff = sqrt(filter(ones(1,tau(i,1))./tau(i,1),1,[signal_eff(1:no_value); signal_eff(1:tau(i,1)-1,1); 0 ] ));
werte_eff_H(:,i) = zb_werte_eff(0+tau(i,1):no_value+tau(i,1),1);
end
werte_eff_H = werte_eff_H(1:end-1,:);
end
I'd like to check, whether there is a possible vectorisation of the internal loop by any matrix-calculations.

回答 (0 件)

この質問は閉じられています。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by