私はthis linkからいくつかの助けを借りて解決策を作成しました:
function newArray = removeOutliers(oldArray, driftAllowance)
% Remove elements from an array that are more than a certain amount from
% the median of an old array
r = size(oldArray, 1); % find the length of the array
r2 = 1; % a new row index for a new table
medianData = [3 5];
medianX = medianData(1);
medianY = medianData(2);
for i = 1 : r % for every row in the array
% If it is within the drift limits of the median
if oldArray(i,1) <= medianX + (driftAllowance/2)...
&& oldArray(i,1) >= medianX - (driftAllowance/2)...
&& oldArray(i,2) <= medianY + (driftAllowance/2)...
&& oldArray(i,2) >= medianY - (driftAllowance/2)
newArray(r2,:) = oldArray(i,:); % add it to a new array
r2 = r2 + 1; % move the new row index on
end
end
あなたのソリューションは、あまりにも動作します!そしてはるかに簡単です。ありがとうございました。 – CaptainProg