How to set multiple values of a threshold?
Afficher commentaires plus anciens
My threshold is 12. If I will get positive values greater than and equal to 12 then I have to set it 1. If I will get negatives values greater than and equal to -12 then I have to set it -1 and all other values that are smaller than -12 and 12 as 0. So how can I set this threshold. In my example valueX1_21 should be -1 but it is 0. How can I get this as -1? Below is my code.
tolX1_4 = [1 1 1 1 1 -1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1];
tolX1_21 = [ -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 0 -1 -1 -1 -1 -1 -1];
tolX1_22 = [ 0 0 0 0 0 0 0 0 0 -1 -1 0 0 -1 0 0 -1 -1 0 0 0 0 0 0];
SumX1_4 = sum(tolX1_4)
SumX1_21 = sum(tolX1_21)
SumX1_22 = sum(tolX1_22)
threshold = 12;
valueX1_4 = double(SumX1_4 >= threshold)
valueX1_21 = double(SumX1_21 >= threshold)
valueX1_22 = double(SumX1_22 >= threshold)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Simulink dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!