Circular buffer &counter

조회 수: 19 (최근 30일)
sanjai 2020년 8월 6일
댓글: sanjai 2020년 10월 8일
I have a two circular buffer (A&B). and i have one array. and counter.
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일
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)
persistent buffer;
if isempty(buffer)
if isequal(numel(IC),bufferLength)
buffer = IC;
elseif isscalar(IC)
buffer = IC*ones(1,bufferLength);
error('IC must either be scalar or the same dimensions as buffer length')
% 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 2020년 10월 8일
what is 'u' and 'IC'

댓글을 달려면 로그인하십시오.


Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by