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

1 visualización (últimos 30 días)
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

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by