Comparator block in simulink

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

Respuestas (2)

Jason Ghidella
Jason Ghidella el 27 de Mzo. de 2013

2 votos

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).

3 comentarios

Caroline Rosa
Caroline Rosa el 29 de Mzo. de 2013
thanks for your tip Jason
santhiya Balachandar
santhiya Balachandar el 29 de Nov. de 2020
Thanks a lot
JongUn
JongUn el 3 de En. de 2025
Thank you very much!

Iniciar sesión para comentar.

Azzi Abdelmalek
Azzi Abdelmalek el 24 de Mzo. de 2013

1 voto

If you want to compare signal1 and signal2 use two block:
  1. sum block to get signal1-signal2
  2. compare to constant block where you will set constant value to 0. The input of this block is signal1-signal2

4 comentarios

Caroline Rosa
Caroline Rosa el 24 de Mzo. de 2013
Thanks Azzi.
paranandi lakshmi narayana
paranandi lakshmi narayana el 24 de Feb. de 2016
sir what is the use of the constant block.actually in my project need to compare 2 signals.Is sum block is enough or need use constant block if necessary how please explain me sir
Boubker Boutalha
Boubker Boutalha el 14 de En. de 2020
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
Wael Atiyah el 28 de Mzo. de 2022
Dear Mr.Abdalmalek
your suggestion not clear wirh respect to me , possible more clarrification

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 24 de Mzo. de 2013

Comentada:

el 3 de En. de 2025

Community Treasure Hunt

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

Start Hunting!

Translated by