I want to know the method for removing excessive angle data.

1 view (last 30 days)
I want to remove data, if current direction larger or smaller about mean current direction +15, - 15(degree), respectively.
First figre, I can remove data by up and down line(mean current direction +15 or -15)
But case of Figure2, some datas exceed 360(degree), So I don't how to remove unneedful data....
  4 Comments
Mann Baidi
Mann Baidi on 29 Feb 2024
for i = 1:length(Current_dir)
indind{i} = find(Current_dir(i,:) > mean_Current_dir(i) + 15 | Current_dir(i,:) < mean_Current_dir(i) - 15);
end
What is the significance of 'indind' variable?
재혁
재혁 on 29 Feb 2024
This is a variable used to identify values that exceed or fall short of 15 degrees from the mean flow direction.

Sign in to comment.

Answers (1)

Mathieu NOE
Mathieu NOE on 29 Feb 2024
hello @재혁
IMO , there is no need to use a for loop to compute 'indind' variable
also nanmean is obsolete, you can use mean with 'omitnan' option instead.
here a very simplified code to show how to remove (replace) values exceeding your limits with NaN's
Current_dir = 45*rand(100,1); % random numbers between 0 and 45
% mean_Current_dir = nanmean(Current_dir,2); obsolete
mean_Current_dir = mean(Current_dir,'omitnan');
%% No need for a for loop here
% for i = 1:length(Current_dir)
% indind{i} = find(Current_dir(i,:) > mean_Current_dir(i) + 15 | Current_dir(i,:) < mean_Current_dir(i) - 15);
% end
indind = (Current_dir > mean_Current_dir + 15) | (Current_dir < mean_Current_dir - 15);
% create data and remove values above and below threshold
Current_dir_cor = Current_dir;
Current_dir_cor(indind) = NaN;
scatter(1:numel(Current_dir),Current_dir); hold on
scatter(1:numel(Current_dir),Current_dir_cor,'*');
yline(mean_Current_dir);
yline(mean_Current_dir+15);
yline(mean_Current_dir-15);

Tags

Community Treasure Hunt

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

Start Hunting!