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

1 次查看(过去 30 天)
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 个评论
Mann Baidi
Mann Baidi 2024-2-29
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?
재혁
재혁 2024-2-29
This is a variable used to identify values that exceed or fall short of 15 degrees from the mean flow direction.

请先登录,再进行评论。

回答(1 个)

Mathieu NOE
Mathieu NOE 2024-2-29
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);

类别

Help CenterFile Exchange 中查找有关 Visualize Data 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by