フィルターのクリア

Circular buffer &counter

18 ビュー (過去 30 日間)
sanjai
sanjai 2020 年 8 月 6 日
コメント済み: sanjai 2020 年 10 月 8 日
I have a two circular buffer (A&B). and i have one array. and counter.
operation:
Each value in the array will go and settle down in the circular buffer A. simulateonsly counter is also countes. these counted values stored in the circular buffer B.
i want to know how to implement in matlab code.

回答 (1 件)

Aman Vyas
Aman Vyas 2020 年 8 月 11 日
編集済み: Aman Vyas 2020 年 8 月 11 日
Hi,
Based on the information provided you can proceed like this:
1) Enter the array as input to matlab function ( Representing Circular buffer)
2) For circular buffer you can try this matlab code in the function.
function y = fcn(u,IC, bufferLength)
%#codegen
persistent buffer;
if isempty(buffer)
if isequal(numel(IC),bufferLength)
buffer = IC;
elseif isscalar(IC)
buffer = IC*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
3) With each buffer update, you can update counter variable and send that as an input to the next circular buffer, which in turn would keep storing values.
Hope it helps !
  1 件のコメント
sanjai
sanjai 2020 年 10 月 8 日
what is 'u' and 'IC'

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by