Simulink If function to change the out put based on input

4 vues (au cours des 30 derniers jours)
Ganeswara Rao Ganta
Ganeswara Rao Ganta le 1 Juil 2019
Modifié(e) : Raj le 1 Juil 2019
Hello all
I am looking for a simulink function that shall output 1 if the input is positie and output -1 if the input is negative. I believe this i is simple but I have no clue how to do this. Can someone please help me with this?

Réponse acceptée

Raj
Raj le 1 Juil 2019
Modifié(e) : Raj le 1 Juil 2019
Use sign
function output = myfunc(input)
output=sign(input);
end
BTW what happens if input is zero? you have not mentioned that. Modify the function accordingly!!
Edit1: Just noticed you have mentioned "simulink function". You can use the sign/signum block. See here.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by