I'm working on a function that runs through an array and elements outside a certain threshold become NaN. Although I can't get the elements above/below the threshold to be omitted (NaN).
function [p] = filtering(fc,thresh1,thresh2)
p = fc;
% Set threshold
for i = 1:fc
if fc >=thresh2
p = NaN;
elseif fc <= thresh1
p = NaN;
else
continue
end
end
end
Thanks in advance!!

 채택된 답변

Walter Roberson
Walter Roberson 2018년 1월 17일
p = fc;
p(p <= thresh1 | p >= thresh2) = NaN;

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 NaNs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by