Comparator block in simulink
406 次查看(过去 30 天)
显示 更早的评论
What is the block i can use in simulink that makes a comparison between two signals? I tried the block named "comparator" from "Simelectronics library" but it dosen't work because it doesn't enable connecting my inputs on it. thanks
回答(2 个)
Jason Ghidella
2013-3-27
An alternative is to use the built-in block "Relational Operator" block from the Logic and Bit Operations library in Simulink. There are other blocks in the library that you may also what to use.
A piece of advice though is the watch out for data type issues. If you are comparing doubles then you may not always get the result you are expecting due to the floatign point precisions of your machince, (eps).
Azzi Abdelmalek
2013-3-24
If you want to compare signal1 and signal2 use two block:
- sum block to get signal1-signal2
- compare to constant block where you will set constant value to 0. The input of this block is signal1-signal2
4 个评论
Boubker Boutalha
2020-1-14
Thanks Abdelmalek !
To @Paranandi Lakshmi Narayana , with the solution proposed by @Azzi Abdelmalek, you still compare the signals, it is just applied the differential comparison to a costant.
For example, your signals are A and B, that could be numbers. You could compare them directly, like as follow:
A > B ; A greater than B
Or instead applying the differential, you do the following:
A > B ----> (A - B) > (B - B) ----> (A - B) > 0 ;
So, tell that A is greater than B, correspond to have (A - B) greater than the constant 0 (zero).
Kind regards,
Boubker
Wael Atiyah
2022-3-28
Dear Mr.Abdalmalek
your suggestion not clear wirh respect to me , possible more clarrification
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 General Applications 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!