Optimize online weighted kurtosis algorithm

Hi all,
I am currently working on a Simulink block designed to perform an online computation of the weighted kurtosis typical of a certain signal. This block is part of a larger control algorithm, which will then be compiled as a DLL and run in both simulations and lab tests.
So far the Simulink block diagram is as follows.
The circular buffer performs the following
function y = fcn(u,bufferIC,bufferLength)
persistent buffer;
if isempty(buffer)
if isequal(numel(bufferIC),bufferLength)
buffer = bufferIC;
elseif isscalar(bufferIC)
buffer = bufferIC*ones(1,bufferLength);
else
error('IC must either be scalar or the same dimensions as buffer length')
end
end
% Output
y = buffer;
% Update
buffer = [u buffer(1:end-1)];
end %fcn
and the weighted kurtosis will then be calculated according to the following algorithm:
function WKurt = fcn(BuffSig)
N = length(BuffSig);
y = (1.005.^(1:N));
weights = 2*(y/max(y));
WMean = sum((weights.*BuffSig))/sum(weights);
WStd = sqrt(sum(weights.*((BuffSig - WMean).^2))/sum(weights));
WKurt = squeeze(((sum(weights.*((((BuffSig - WMean)./WStd)).^4))/sum(weights))) - 3);
WKurt(WKurt<0) = 0.0;
WKurt(isnan(WKurt)) = 0.0;
WKurt(isinf(WKurt)) = 0.0;
If I run simulations, everything is alright and I do not happen into any CPU computation issue. That does not hold valid as soon as I move to lab tests, which will be terminated because the block requires too much CPU memory.
Therefore, I would very much appreciate whether a work-around exists so as to achieve the same kurtosis estimation, but in a more CPU-effcient way.

Respuestas (0)

Categorías

Más información sobre Simulink Coder en Centro de ayuda y File Exchange.

Preguntada:

el 29 de Jun. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by