Detect in simulink if the current and past 4 values are same or not
古いコメントを表示
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?
採用された回答
その他の回答 (2 件)
Anthony Poulin
2015 年 7 月 2 日
0 投票
Hello,
Do the picture attached solve your question?
2 件のコメント
Abubakar Muqaddas
2015 年 7 月 2 日
Azzi Abdelmalek
2015 年 7 月 2 日
Abubakar, why do you think they are not compared at the same time?
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];
カテゴリ
ヘルプ センター および File Exchange で Sources についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!