Subtraction of set value from specific elements in column once criteria met

4 vues (au cours des 30 derniers jours)
CH
CH le 30 Mai 2021
Commenté : CH le 31 Mai 2021
Hi everyone,
I'm using this device that outputs counts in a set column. The problem is when the count goes negative the output goes to the max positive number (65535) and starts counting down. So the column could out put values such as (1790, 30,1500, 65530....).
I'm hoping to subtract 65535 from these "negative" values to get the true negative value (1790,30,1500, -5). The positive count will never go above 5000 so I was trying to subtract 65535 from every element above a set limit but not having any luck. I haven't been able to set it up so that any value above some set limit is subtract by 65535. I've just ended up setting all values to that set value.
I'd appreaciate any assistance.
Thanks in advance

Réponse acceptée

the cyclist
the cyclist le 30 Mai 2021
threshold = 5000; % Set this to the limit value you want
x(x>threshold) = x(x>threshold) - 65535;

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by