필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
재혁
재혁 2024년 2월 29일
답변: Mathieu NOE 2024년 2월 29일
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