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

조회 수: 4 (최근 30일)
CH
CH 2021년 5월 30일
댓글: CH 2021년 5월 31일
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

채택된 답변

the cyclist
the cyclist 2021년 5월 30일
threshold = 5000; % Set this to the limit value you want
x(x>threshold) = x(x>threshold) - 65535;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by