Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
Rakesh Yadav Kodari
Rakesh Yadav Kodari am 12 Feb. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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

Antworten (1)

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

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by