I want to know the method for removing excessive angle data.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1631236/image.png)
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)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1631241/image.png)
But case of Figure2, some datas exceed 360(degree), So I don't how to remove unneedful data....
4 commentaires
Mann Baidi
le 29 Fév 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?
Réponses (1)
Mathieu NOE
le 29 Fév 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);
0 commentaires
Voir également
Catégories
En savoir plus sur Visualize Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!