필터 지우기
필터 지우기

Detect in simulink if the current and past 4 values are same or not

조회 수: 3 (최근 30일)
Hi, I am interested in designing a simulink block which detects if the past 4 and the current input values are same or not. How to do it using the delay blocks and relational operators since the relational operators take only two inputs at a time?

채택된 답변

Titus Edelhofer
Titus Edelhofer 2015년 7월 2일
You can use 4 delay blocks, and feed x_t and x_{t-1} into one relational block, x_{t-1} and x_{t-2} into the next relational block, and then use AND blocks to combine.
Titus

추가 답변 (2개)

Anthony Poulin
Anthony Poulin 2015년 7월 2일
Hello,
Do the picture attached solve your question?
  댓글 수: 2
Abubakar Muqaddas
Abubakar Muqaddas 2015년 7월 2일
No, since it doesn't compare all the past 5 values at the same time
Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 2일
Abubakar, why do you think they are not compared at the same time?

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


Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 2일
편집: Azzi Abdelmalek 2015년 7월 2일
You can use Matlab function without any delay block.
function y = fcn(u)
%#codegen
persistent u1 u2 u3 u4
if isempty(u1)
[u1,u2,u3,u4]=deal(0)
end
y=isequal(u,u1,u2,u3,u4)
u4=u3
u3=u2
u2=u1
u1=u
Or
function y = fcn(u)
%#codegen
persistent u1
if isempty(u1)
u1=zeros(1,4)
end
a=[u u1];
y=~any(diff(a));
u1=[u1(2:4) u];

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by