필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Substract only higher then a limit? Please find the example program below.

조회 수: 1 (최근 30일)
Rakesh Yadav Kodari
Rakesh Yadav Kodari 2019년 2월 12일
마감: MATLAB Answer Bot 2021년 8월 20일
Suppose
dataI = [100;200;300;100;200;300];
limit = 150;
if any(dataI >= limit)
disp('There is at least one value above the limit.')
DataI_with_Neg = dataI - 100; %% Here I want to sub 100 from all the values which are higher than limit = 150 and get new data after sub%%
else
disp('All values are below the limit.')
end

답변 (1개)

madhan ravi
madhan ravi 2019년 2월 12일
편집: madhan ravi 2019년 2월 12일
DataI_with_Neg = dataI(dataI > limit) - 100;
% ^^^^^^^^^^^^^^^--- add this (datas which are higher than 150)
  댓글 수: 6
madhan ravi
madhan ravi 2019년 2월 12일
편집: madhan ravi 2019년 2월 12일
Ah thank you John D'Errico & Stephen Cobeldick now it's clear what the OP wants.
Rakesh Yadav Kodari
Rakesh Yadav Kodari 2019년 2월 12일
Thank you all.
Code from John D'Errico worked.
loc = dataI >= 150;
dataI(loc) = dataI(loc) - 100;

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by